Difference between revisions of "Obj.in.box"
(Created page with "The '''obj.in.box''' command returns TRUE if the entire bottom row of pixels of the screen object is within a specified region. == Syntax == obj.in.box(screen object|o...") |
m (→Remarks) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
The position test commands ('''[[posn]]''', '''[[center.posn]]''', '''[[right.posn]]''', and '''obj.in.box''' are used to determine if a screen object's position is within a certain area. | The position test commands ('''[[posn]]''', '''[[center.posn]]''', '''[[right.posn]]''', and '''obj.in.box''' are used to determine if a screen object's position is within a certain area. | ||
− | The '''obj.in.box''' command checks for the entire bottom row | + | The '''obj.in.box''' command checks for the entire baseline (bottom row of the current [[cel]]) of [[screen object]] '''oA''' to be within a bounded area, instead of just a single reference pixel, like the other position test commands. |
− | The region to be tested is bounded by ('''X1''', '''Y1''') - ('''X2''', '''Y2'''). The test returns TRUE if the object' | + | The region to be tested is bounded by ('''X1''', '''Y1''') - ('''X2''', '''Y2'''). The test returns TRUE if the entire baseline of [[screen object]] '''oA''' is >= '''X1''' AND <= '''X2''' AND >= '''Y1''' AND <= '''Y2'''. |
− | This test command can be combined with the | + | This test command can be combined with the <code>NOT</code> operator to test if an object is NOT in a specified region. |
== Possible Errors == | == Possible Errors == | ||
+ | |||
+ | AGI does not check that object number '''oA''' is a valid [[screen object]]. If it is not, the '''obj.in.box''' command will access invalid memory and the result of the test will be meaningless. | ||
AGI expects the coordinates to be in upper-left to lower-right format. '''X1''' ''must'' be less than or equal to '''X2''' and '''Y1''' ''must'' be less than or equal to '''Y2''', or the test will always fail. | AGI expects the coordinates to be in upper-left to lower-right format. '''X1''' ''must'' be less than or equal to '''X2''' and '''Y1''' ''must'' be less than or equal to '''Y2''', or the test will always fail. |
Latest revision as of 10:28, 20 April 2019
The obj.in.box command returns TRUE if the entire bottom row of pixels of the screen object is within a specified region.
Syntax
obj.in.box(obj oA, byt X1, byt Y1, byt X2, byt Y2)
Remarks
Test commands are only valid in an if
statement.
The position test commands (posn, center.posn, right.posn, and obj.in.box are used to determine if a screen object's position is within a certain area.
The obj.in.box command checks for the entire baseline (bottom row of the current cel) of screen object oA to be within a bounded area, instead of just a single reference pixel, like the other position test commands.
The region to be tested is bounded by (X1, Y1) - (X2, Y2). The test returns TRUE if the entire baseline of screen object oA is >= X1 AND <= X2 AND >= Y1 AND <= Y2.
This test command can be combined with the NOT
operator to test if an object is NOT in a specified region.
Possible Errors
AGI does not check that object number oA is a valid screen object. If it is not, the obj.in.box command will access invalid memory and the result of the test will be meaningless.
AGI expects the coordinates to be in upper-left to lower-right format. X1 must be less than or equal to X2 and Y1 must be less than or equal to Y2, or the test will always fail.
Example
<syntaxhighlight lang="agi"> if(obj.in.box(o1, 0, 120, 60, 130))
{ print("the object's entire bottom row is in the box"); }
</syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 16 (0x10 hex) |