Set.loop.v

From AGI Wiki
Revision as of 13:29, 21 April 2019 by Andrew Korson (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The set.loop.v command assigns a loop to a screen object indirectly.

Syntax

set.loop.v(obj oA, var vLOOP);

Remarks

The current loop of screen object oA is set to the value of variable vLOOP.

A view must be be assigned to the object first. If a view is not assigned, AGI raises trappable error #6. If vLOOP is not a valid loop number, i.e. it exceeds the maximum number of available loops in the view, AGI raises trappable error #5.

Be aware that there is a bug in all versions of AGI affecting the check for valid loop numbers. AGI only returns trappable error #5 if the value of vLOOP is GREATER than the total number of loops in the view. However, since loops are zero based (first loop is 0, second loop is one, etc.), the last valid loop would be total loop count minus one. If vLOOP is EQUAL to the loop count, AGI doesn't raise an error, but the loop number is actually invalid, and using it will almost always end up in crashing AGI.

When the loop changes, AGI checks to see if the current cel of the screen object is now greater than the last cel in newly assigned loop. If it is, the cel is reset to 0; if not the screen object's cel value is not changed.

Possible Errors

In version 2.089 only, AGI raises trappable error #4 if object number oA is invalid. In all later versions, AGI does not check that object number oA is a valid object. If it is not, this command will overwrite other data on the memory heap, which may cause unexpected results, including possibly crashing AGI.

Example

Code:

<syntaxhighlight lang="agi"> [ typical code to add a static view indirectly animate.obj(o1); load.view(8); set.view(o1, 8); v50 = 1; set.loop.v(o1, v50); set.cel(o1, 2); position(o1, 20, 132); stop.cycling(o1); draw(o1); </syntaxhighlight>

Technical Information

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

See Also

set.cel
set.cel.v
set.loop
set.view
set.view.v