Difference between revisions of "New.room"
From AGI Wiki
Jump to navigationJump to searchLine 73: | Line 73: | ||
* [[set.horizon]] | * [[set.horizon]] | ||
* [[Special Variables|Special variables]] | * [[Special Variables|Special variables]] | ||
− | * [[Special | + | * [[Special Flags|Special Flags]] |
* [[Defines]] | * [[Defines]] | ||
Revision as of 01:11, 10 March 2018
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
- the logic resource must exist, or the game will crash with a logic not found error
Examples
The following code goes to room 25 if ego is touching the left edge of the screen:
Code:
<syntaxhighlight lang="agi">
- define ego_edge_code v2
- 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">
- define ego_edge_code v2
- 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.