Difference between revisions of "Set.dir"
Line 1: | Line 1: | ||
− | set.dir | + | The '''set.dir''' command sets the direction of motion for an object. |
− | + | == Syntax == | |
− | + | set.dir([[screen object|obj]] oA, [[variable|var]] vDIR); | |
− | + | == Remarks == | |
− | == | + | The direction of [[screen object]] '''oA''' is set to the value of [[variable]] '''vDIR''', which should be >= 0 and <= 8. |
− | + | <blockquote>[[File:MovingObjects.png]]</blockquote> | |
+ | |||
+ | Changing the direction does not change the [[movement mode]]. For '''[[move.obj]]''', '''[[move.obj.v]]''' and '''[[follow.ego]]''' modes, changing direction with '''set.dir''' doesn't work, because AGI will automatically change direction back to keep the object moving toward its target. | ||
+ | |||
+ | You cannot set the [[ego]] object's direction with the '''set.dir''' command, not even when it is in [[program.control|program control]] mode. To change ego's direction, you have to change the value of [[reserved variable]] [[v6 (ego direction)]]. | ||
− | + | == Possible Errors == | |
− | + | Using a '''vDIR''' value greater than 8 will cause AGI to [[crashing AGI|crash]] when the [[autoloop]] feature tries to set a [[loop]]. If the autoloop feature is disabled, direction values greater than 8 are still problematic, because AGI uses a lookup table to determine how to adjust the X and Y coordinates of an object based on direction; values greater than 8 exceed the table boundaries and use data meant for other purposes, resulting in unpredictable behavior in object motion. | |
− | + | AGI does not check that object number '''oA''' is a valid [[screen 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 == |
− | [ | + | <div class="CodeBlockHeader">Code:</div> |
+ | <syntaxhighlight lang="agi"> | ||
+ | v52 = 3; | ||
+ | set.dir(o3, v52); [ now object 3 will move to right | ||
+ | </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:''' | ||
+ | | 86 (0x56 hex) | ||
+ | |} | ||
− | + | == See Also == | |
− | [[ | + | '''[[follow.ego]]'''<br /> |
− | [[ | + | '''[[get.dir]]'''<br /> |
− | [[ | + | '''[[move.obj]]'''<br /> |
− | [[Category: | + | '''[[move.obj.v]]'''<br /> |
+ | '''[[normal.motion]]'''<br /> | ||
+ | '''[[wander]]'''<br /> | ||
+ | [[Category:Commands]]<br /> |
Latest revision as of 22:48, 20 April 2019
The set.dir command sets the direction of motion for an object.
Syntax
Remarks
The direction of screen object oA is set to the value of variable vDIR, which should be >= 0 and <= 8.
Changing the direction does not change the movement mode. For move.obj, move.obj.v and follow.ego modes, changing direction with set.dir doesn't work, because AGI will automatically change direction back to keep the object moving toward its target.
You cannot set the ego object's direction with the set.dir command, not even when it is in program control mode. To change ego's direction, you have to change the value of reserved variable v6 (ego direction).
Possible Errors
Using a vDIR value greater than 8 will cause AGI to crash when the autoloop feature tries to set a loop. If the autoloop feature is disabled, direction values greater than 8 are still problematic, because AGI uses a lookup table to determine how to adjust the X and Y coordinates of an object based on direction; values greater than 8 exceed the table boundaries and use data meant for other purposes, resulting in unpredictable behavior in object motion.
AGI does not check that object number oA is a valid screen 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
<syntaxhighlight lang="agi"> v52 = 3; set.dir(o3, v52); [ now object 3 will move to right </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 86 (0x56 hex) |