Difference between revisions of "Set.loop.v"

From AGI Wiki
Jump to navigationJump to search
(Created page with "set.loop.v   == <br />Syntax == <blockquote><code>set.loop.v(oA,vB);</code></blockquote>   == Description == The current loop of object oA is set to vB. If an i...")
 
 
Line 1: Line 1:
set.loop.v
+
The '''set.loop.v''' command assigns a loop to a screen object indirectly.
  
&nbsp;
+
== Syntax ==
  
== <br />Syntax ==
+
set.loop.v([[screen object|obj]] oA, [[variable|var]] vLOOP);
  
<blockquote><code>set.loop.v(oA,vB);</code></blockquote>
+
== Remarks ==
  
&nbsp;
+
The current [[loop]] of [[screen object]] oA is set to the value of [[variable]] '''vLOOP'''.
== Description ==
 
  
The current loop of object oA is set to vB. If an invalid loop number is given, the interpreter generates an error. If the current cel of the object is greater than the last cel in loop vB, then the current cel is set to 0.
+
A [[View Resource (AGI)|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]].
  
&nbsp;
+
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]].
== Sources ==
 
  
[[AGI Studio Help File]]
+
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.
  
&nbsp;
+
== Possible Errors ==
  
== See also ==
+
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]].
  
* <code>[[set.loop]]</code>
+
== Example ==
* <code>[[current.loop]]</code>
 
* <code>[[number.of.loops]]</code>
 
* <code>[[set.cel]]</code>
 
* <code>[[set.cel.v]]</code>
 
* <code>[[Cycling objects]]</code>
 
  
&nbsp;
+
<div class="CodeBlockHeader">Code:</div>
 +
<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>
  
[[Category:Object Commands]]
+
== Technical Information ==
[[Category:View Commands]]
+
 
 +
{| 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:'''
 +
| 44 (0x2C hex)
 +
|}
 +
 
 +
== See Also ==
 +
 
 +
'''[[set.cel]]'''<br />
 +
'''[[set.cel.v]]'''<br />
 +
'''[[set.loop]]'''<br />
 +
'''[[set.view]]'''<br />
 +
'''[[set.view.v]]'''<br />
 +
[[Category:Commands]]<br />

Latest revision as of 13:29, 21 April 2019

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:
[ 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);

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