Difference between revisions of "New.room"
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | The | + | The '''new.room''' command changes the current room number and forces an update. |
− | + | == Syntax == | |
− | + | new.room([[number|byt]] ROOMNUM); | |
− | + | == Remarks == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The '''new.room''' command causes AGI to halt execution of the current [[logic]] script. The current [[room]] number is changed to '''ROOMNUM'''. The resources on the [[memory heap]] are dumped (with the exception of [[logic 0]]). The following actions are then taken to switch to the new room: | |
− | + | # if a [[sound]] is playing, it is stopped and the 'done' [[flag]] is set to TRUE; | |
+ | # the [[memory heap]] is cleared by resetting the memory pointer to [[room.0]]; | ||
+ | # the [[keyboard]] buffer and [[controller flag table]] are cleared; | ||
+ | # the [[script]] table is cleared; | ||
+ | # the [[screen objects table]] is cleared - for each [[screen object]], the DRAWN and ANIMATED flags are cleared and the UPDATE flag is set; and the [[step size]], [[step time]], step counter, [[cycle time]] and cycle counter properties are set to 1; | ||
+ | # all resource linked lists are cleared; | ||
+ | # [[ego]]is set to [[player.control|player control]]; | ||
+ | # if a [[block]] is set, it is cleared; | ||
+ | # the [[horizon]] is set to default value of 36; | ||
+ | # [[reserved variable]] [[v0 (current room)]] is copied to reserved variable [[v1 (previous room)]];, and v0 is set to '''ROOMNUM'''; | ||
+ | # [[reserved variable|reserved variables]] [[v4 (object touching edge)]] and [[v5 (object edge code)]] are set to zero; | ||
+ | # [[reserved variable]] [[v16 (ego view number)]] is set to current [[ego]] [[view]] number; | ||
+ | # all open [[VOL files]] are closed (they will automatically be reopened when the [[logic]] for this room is loaded); | ||
+ | # the [[logic]] for new room ([[reserved variable]] [[v0 (current room)]]) is loaded (note that the logic is loaded, but is not [[called]] automatically; you should use the '''[[call.v]]''' command in [[logic 0]] to call the room's logic in each [[interpreter cycle]]); | ||
+ | # if a [[trace.info|trace logic]] has been specified, it gets loaded; | ||
+ | # if [[ego]] was touching an edge in the previous room, it is positioned to opposite side of the new room ( i.e. if ego touched right edge, it is moved to left edge); | ||
+ | # [[reserved variable]] [[v2 (ego edge code)]] is set to zero; | ||
+ | # [[reserved flag]] [[f5 (new room)]] is set to TRUE; | ||
+ | # the [[controller]] flag table is cleared; | ||
+ | # the [[status line]], if enabled, is redrawn; | ||
+ | # the [[input line]], if enabled, is redrawn, any text already on the input line before the '''new.room''' call is maintained; | ||
+ | # [[reserved variable|reserved variables]] [[v4 (object touching edge)]], [[v5 (object edge code)]] and [[v9 (unknown word number)]] are set to zero; | ||
+ | # [[reserved flag]] [[f2 (input received)]] is reset to FALSE (but reserved flag [[f4 (said found match) is not modified; this appears to be a minor bug, but it usually not an issue); | ||
+ | # [[reserved variable]] [[v3(current score)]] is cached; | ||
+ | # the [[interpreter cycle|cycle]] is then continued by jumping to the point where [[logic 0]] is executed. | ||
− | + | Keep in mind that the '''new.room''' command interrupts the [[interpreter cycle]], so any commands after a '''new.room''' command will never get executed. | |
− | + | Also note that the '''new.room''' command does not affect the current display mode ([[graphics]] or [[text.screen|text]]); it will remain in the same mode. | |
+ | == Possible Errors == | ||
− | + | If the logic matching '''ROOMNUM''' does not exist, AGI will raise a [[runtime error]] and crash. | |
− | + | == Example == | |
− | |||
− | |||
− | == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
− | + | [ typical code that changes rooms when ego reaches an edge | |
− | + | if (edgeEgoHit == LEFT) | |
− | + | { | |
− | if ( | + | new.room(75); |
− | { | + | } |
− | |||
− | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Technical Information == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {| border="1" cellpadding="2" | |
+ | | style="background-color: #efefef" width="200" | '''Required Interpreter Version:''' | ||
+ | | width="175" | Available in all AGI versions. | ||
+ | |- | ||
+ | | style="background-color: #efefef" | '''Byte-Code Value:''' | ||
+ | | 18 (0x12 hex) | ||
+ | |} | ||
− | + | == See Also == | |
− | [[ | + | '''[[new.room.v]]'''<br /> |
− | [[Category: | + | [[Category:Commands]]<br /> |
Latest revision as of 17:56, 12 April 2019
The new.room command changes the current room number and forces an update.
Syntax
new.room(byt ROOMNUM);
Remarks
The new.room command causes AGI to halt execution of the current logic script. The current room number is changed to ROOMNUM. The resources on the memory heap are dumped (with the exception of logic 0). The following actions are then taken to switch to the new room:
- if a sound is playing, it is stopped and the 'done' flag is set to TRUE;
- the memory heap is cleared by resetting the memory pointer to room.0;
- the keyboard buffer and controller flag table are cleared;
- the script table is cleared;
- the screen objects table is cleared - for each screen object, the DRAWN and ANIMATED flags are cleared and the UPDATE flag is set; and the step size, step time, step counter, cycle time and cycle counter properties are set to 1;
- all resource linked lists are cleared;
- egois set to player control;
- if a block is set, it is cleared;
- the horizon is set to default value of 36;
- reserved variable v0 (current room) is copied to reserved variable v1 (previous room);, and v0 is set to ROOMNUM;
- reserved variables v4 (object touching edge) and v5 (object edge code) are set to zero;
- reserved variable v16 (ego view number) is set to current ego view number;
- all open VOL files are closed (they will automatically be reopened when the logic for this room is loaded);
- the logic for new room (reserved variable v0 (current room)) is loaded (note that the logic is loaded, but is not called automatically; you should use the call.v command in logic 0 to call the room's logic in each interpreter cycle);
- if a trace logic has been specified, it gets loaded;
- if ego was touching an edge in the previous room, it is positioned to opposite side of the new room ( i.e. if ego touched right edge, it is moved to left edge);
- reserved variable v2 (ego edge code) is set to zero;
- reserved flag f5 (new room) is set to TRUE;
- the controller flag table is cleared;
- the status line, if enabled, is redrawn;
- the input line, if enabled, is redrawn, any text already on the input line before the new.room call is maintained;
- reserved variables v4 (object touching edge), v5 (object edge code) and v9 (unknown word number) are set to zero;
- reserved flag f2 (input received) is reset to FALSE (but reserved flag [[f4 (said found match) is not modified; this appears to be a minor bug, but it usually not an issue);
- reserved variable v3(current score) is cached;
- the cycle is then continued by jumping to the point where logic 0 is executed.
Keep in mind that the new.room command interrupts the interpreter cycle, so any commands after a new.room command will never get executed.
Also note that the new.room command does not affect the current display mode (graphics or text); it will remain in the same mode.
Possible Errors
If the logic matching ROOMNUM does not exist, AGI will raise a runtime error and crash.
Example
<syntaxhighlight lang="agi"> [ typical code that changes rooms when ego reaches an edge if (edgeEgoHit == LEFT)
{ new.room(75); }
</syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 18 (0x12 hex) |