Reverse.loop

From AGI Wiki
Revision as of 07:00, 20 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''reverse.loop''' command switches an object's cycle mode to 'reverse loop'. == Syntax == reverse.loop(obj oA, flg fDONE); == Remarks ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The reverse.loop command switches an object's cycle mode to 'reverse loop'.

Syntax

reverse.loop(obj oA, flg fDONE);

Remarks

In the 'reverse loop' cycle mode, screen object oA will cycle one time, in the reverse direction, until the first cel is reached.

Setting the cycle mode to 'reverse loop' will automatically enable the object for updating if not currently enabled, and also enables the cycling property.

Flag fDONE is reset to FALSE when the command is executed. When the first cel is reached, fDONE is set to TRUE.

Changing cycle mode does not change the current cel. The new cycle mode begins with whatever cel is currently assigned to the object. If the current cel is the first cel, no cycling will occur, as the screen object is already at the beginning of the loop. Flag fDONE will be set immediately.

Use the stop.cycling command to turn cycling off. The normal.cycle, end.of.loop and reverse.cycle commands can be used to switch to other cycle modes.

Possible Errors

Do not use reverse.loop and movement modes (move.obj, follow.ego or wander) one an object at the same time. The byte in the screen object data table that AGI uses to store the fDONE flag is also used by the movement modes. If you use a movement mode command while the reverse.loop command is active, the flag number gets overwritten, and when the object finishes cycling, the wrong flag will be set.

AGI does not check that object number oA is a valid screen object. If the object has not been initialized, the reverse.loop command still sets the cycle mode to 'reverse loop' and resets the flag; nothing else will happen though. If the object number exceeds the max screen object number, data used for other purposes will be overwritten, which may result in unexpected results, including possibly crashing AGI.

Example

Code:

<syntaxhighlight lang="agi">

  1. define door o7

... [ initialize object ... reverse.loop(door, f99); [ close the door if(isset(f99))

 {
 print("The door is shut.");
 reset(f99);
 }

... end.of.loop(door, f100); [ open the door if(isset(f100))

 {
 print("The door is open.");
 reset(f100);
 }

</syntaxhighlight>

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 75 (0x4B hex)

See Also

end.of.loop
normal.cycle
reverse.cycle
stop.cycling