Difference between revisions of "New.room"

From AGI Wiki
Jump to navigationJump to search
Line 42: Line 42:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
#define ego_edge_code v2
 
#define ego_edge_code v2
Line 51: Line 50:
 
     new.room(25);
 
     new.room(25);
 
}
 
}
</syntaxhighlight></div>
+
</syntaxhighlight>
 
 
  
 
The next example accomplishes the same task with <code>new.room.v</code>:
 
The next example accomplishes the same task with <code>new.room.v</code>:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
#define ego_edge_code v2
 
#define ego_edge_code v2
Line 67: Line 64:
 
   new.room.v(v202);
 
   new.room.v(v202);
 
}
 
}
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
== See also ==
 
== See also ==

Revision as of 00:21, 26 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


Examples

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

Code:
#define ego_edge_code v2
#define left_edge      4

if (ego_edge_code == left_edge)
{
    new.room(25);
}

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

Code:
#define ego_edge_code v2
#define left_edge      4

if (ego_edge_code == left_edge)
{
   v202 = 25;
   new.room.v(v202);
}

See also

Sources

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