Set.dir
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) |