Object.on.land

From AGI Wiki
Revision as of 22:50, 13 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''object.on.land''' command restricts a screen object from going entirely on water (areas where priority does not equal 3). == Syntax == object.on.land(screen object|...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The object.on.land command restricts a screen object from going entirely on water (areas where priority does not equal 3).

Syntax

object.on.land(obj oA);

Remarks

Unlike the object.on.water command, the object.on.land command does not restrict screen object oA to only land (i.e. priority pixels > 3). Instead, as long as at least one pixel of the object's baseline is on a non-water pixel, the movement is allowed.

At the start of the next interpreter cycle after object.on.land is executed, AGI will shuffle the position of the object if it is currently entirely on water.

The object.on.land and object.on.water commands do not work on the ego object. Although ego will be repositioned if entirely on water by shuffling as described above, at the end of each interpreter cycle AGI automatically clears any land or water restriction on ego.

Possible Errors

AGI does not check that screen 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.

DO NOT use the object.on.land and object.on.water commands on a screen object at the same time; they do not cancel each other out. If both commands are active on the same screen object, AGI will lock up, because it will enter a never ending loop trying to find a position. Make sure you use the object.on.anything command before switching between object.on.land and object.on.water.

Example

Code:

<syntaxhighlight lang="agi">

#define cat o1  

... [ initialize object object.on.land(cat); [ cats hate water ... object.on.anything(cat); [ teach cat to swim ... object.on.water(cat); [ now cat loves the water; won't come out! </syntaxhighlight>

Technical Information

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

See Also

object.on.anything
object.on.water