From AGI Wiki
Jump to: navigation, search

The block command sets up an invisible rectangular block that can restrict screen object movement.


block(byt X1, byt Y1, byt X2, byt Y2);


Screen objects are not allowed to cross into or out of the bounding rectangle created by the block command, unless an ignore.blocks command has been executed for that object. If an object is inside the block when the block is created, it will not be allowed to move on or outside the block. If the object is outside the block, it will not be allowed to move inside it, but it will move onto the block. Note that this means it is possible for objects to 'jump' over a block if their step size is large enough. AGI uses the leftmost pixel of a screen object's baseline to compare to the block coordinates.

There can only be one block on the screen at a time. If the block command is executed when a block already exists, the new block will replace the old one.The unblock command will remove a block from the screen.

See the Blocks discussion in the Managing Obstacles topic for more information.

Possible Errors

AGI expects the coordinates to be in upper-left to lower-right format. X1 must be less than X2 and Y1 must be less than Y2, or the block will always be ignored by all screen objects.

(X2 - X1) and (Y2 - Y1) must both be greater than 1. If either is not, there will be no 'interior' area inside the block, and the block will always be ignored by all screen objects.


block(25, 25, 100, 100);  [ create a block
ignore.block(o1);         [ object 1 will ignore the block
observe.block(o1);        [ now object 1 will observe the block
unblock();                [ remove the block
[ examples of blocks that will NOT work
block(100, 100, 25, 25);  [ coordinates are in wrong order; this block will never work
block(25, 25, 100, 26);   [ difference is Y value is too small so this block will never work

Technical Information

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

See Also

Screen Object/View Commands unblock
Managing Obstacles