New Room Section

From AGI Wiki
Revision as of 02:07, 29 December 2013 by Andrew Branscom (talk | contribs)
Jump to navigationJump to search

The new room section of a logic is a section of code that runs during the first interpreter cycle in a new room and does not run again unless the player leaves the room and re-enters it. This section is used to perform initialization of the variables, flags, objects, and other data used by the room - in other words, the new room section contains code that you would only want to run once in a room.

The new room section is controlled by the special flag f5 (or new_room, in the AGI Studio Template Game). This flag is set during the first cycle through a new room and is reset after that cycle has completed.

A typical new room section will contain code like the following:

Code:

<syntaxhighlight lang="agi">

 #define new_room f5
 #define room_no  v0
 #define ego      o0
 if (new_room)
 {
   /* new room section */
   load.pic(room_no);
   draw.pic(room_no);
   discard.pic(room_no);
   draw(ego);
   show.pic();
 }

</syntaxhighlight>

 

See also