New.room

From AGI Wiki
Revision as of 17:56, 12 April 2019 by Andrew Korson (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The new.room command changes the current room number and forces an update.

Syntax

new.room(byt ROOMNUM);

Remarks

The new.room command causes AGI to halt execution of the current logic script. The current room number is changed to ROOMNUM. The resources on the memory heap are dumped (with the exception of logic 0). The following actions are then taken to switch to the new room:

  1. if a sound is playing, it is stopped and the 'done' flag is set to TRUE;
  2. the memory heap is cleared by resetting the memory pointer to room.0;
  3. the keyboard buffer and controller flag table are cleared;
  4. the script table is cleared;
  5. the screen objects table is cleared - for each screen object, the DRAWN and ANIMATED flags are cleared and the UPDATE flag is set; and the step size, step time, step counter, cycle time and cycle counter properties are set to 1;
  6. all resource linked lists are cleared;
  7. egois set to player control;
  8. if a block is set, it is cleared;
  9. the horizon is set to default value of 36;
  10. reserved variable v0 (current room) is copied to reserved variable v1 (previous room);, and v0 is set to ROOMNUM;
  11. reserved variables v4 (object touching edge) and v5 (object edge code) are set to zero;
  12. reserved variable v16 (ego view number) is set to current ego view number;
  13. all open VOL files are closed (they will automatically be reopened when the logic for this room is loaded);
  14. the logic for new room (reserved variable v0 (current room)) is loaded (note that the logic is loaded, but is not called automatically; you should use the call.v command in logic 0 to call the room's logic in each interpreter cycle);
  15. if a trace logic has been specified, it gets loaded;
  16. if ego was touching an edge in the previous room, it is positioned to opposite side of the new room ( i.e. if ego touched right edge, it is moved to left edge);
  17. reserved variable v2 (ego edge code) is set to zero;
  18. reserved flag f5 (new room) is set to TRUE;
  19. the controller flag table is cleared;
  20. the status line, if enabled, is redrawn;
  21. the input line, if enabled, is redrawn, any text already on the input line before the new.room call is maintained;
  22. reserved variables v4 (object touching edge), v5 (object edge code) and v9 (unknown word number) are set to zero;
  23. reserved flag f2 (input received) is reset to FALSE (but reserved flag [[f4 (said found match) is not modified; this appears to be a minor bug, but it usually not an issue);
  24. reserved variable v3(current score) is cached;
  25. the cycle is then continued by jumping to the point where logic 0 is executed.

Keep in mind that the new.room command interrupts the interpreter cycle, so any commands after a new.room command will never get executed.

Also note that the new.room command does not affect the current display mode (graphics or text); it will remain in the same mode.

Possible Errors

If the logic matching ROOMNUM does not exist, AGI will raise a runtime error and crash.

Example

Code:
[ typical code that changes rooms when ego reaches an edge
if (edgeEgoHit == LEFT) 
  {
  new.room(75);
  }

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 18 (0x12 hex)

See Also

new.room.v