Difference between revisions of "New.room"
From AGI Wiki
Jump to navigationJump to searchLine 13: | Line 13: | ||
* v0 (room number) is assigned roomNumber | * v0 (room number) is assigned roomNumber | ||
* v16 (ego view number) is set to the [[VIEW Resource|view]] number assigned to [[ego]]. | * v16 (ego view number) is set to the [[VIEW Resource|view]] number assigned to [[ego]]. | ||
− | * The [[ | + | * The [[Logic Resource|logic]] for the new room is loaded (logic roomNumber). |
* If ego was touching an [[Screen Edges|edge of the screen]], it is placed on the opposite side. | * If ego was touching an [[Screen Edges|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). | * [[Flag]] 5 (new room flag) is [[set]] (the flag is [[reset]] after the first cycle in the new room). | ||
Line 34: | Line 34: | ||
== Possible errors == | == Possible errors == | ||
− | * the [[ | + | * the [[Logic Resource|logic resource]] must exist, or the game will crash with a [[Logic Not Found Error |logic not found error ]] |
Revision as of 15:53, 28 December 2013
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.