New.room

From AGI Wiki
Revision as of 22:46, 2 August 2013 by Andrew Branscom (talk | contribs) (Created page with "The new.room command switches the game to a new room. There is an indirect version of this command called '''new.room.v'''. <code>new.room(roomNumber...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The new.room command switches the game to a new room. There is an indirect version of this command called new.room.v.

new.room(roomNumber);

The following things happen automatically when this command is issued:

  • All objects are unanimated.
  • All resources except logic 0 are discarded (removed from memory).
  • The player.control command is executed.
  • The unblock command is executed.
  • The horizon is set to 36.
  • v1 (previous room number) is set to the value of v0 (room number)
  • v0 (room number) is assigned roomNumber
  • v16 (ego view number) is set to the view number assigned to ego.
  • The logic for the new room is loaded (logic roomNumber).
  • If ego was touching an edge of the screen, it is placed on the opposite side.
  • Flag 5 (new room flag) is set (the flag is reset after the first cycle in the new room).
  • Execution jumps to the start of logic 0.

Parameters

For new.room

  • roomNumber: a number, 0-255, specifying which room to switch to


For new.room.v

  • roomNumber: a variable, v0-v255, whose value specifies which room to switch to


Possible errors


Examples

The following code goes to room 25 if ego is touching the left edge of the screen:

Code:

<syntaxhighlight lang="agi">

  1. define ego_edge_code v2
  2. define left_edge 4

if (ego_edge_code == left_edge) {

   new.room(25);

}

</syntaxhighlight>


The next example accomplishes the same task with new.room.v:

Code:

<syntaxhighlight lang="agi">

  1. define ego_edge_code v2
  2. define left_edge 4

if (ego_edge_code == left_edge) {

  v202 = 25;
  new.room.v(v202);

}

</syntaxhighlight>

See also

Sources

Some of the text in this article is taken from the AGI Studio help file.