Has: Difference between revisions
sierraw>Andrew Branscom m 2 revisions imported |
|||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
The '''has''' command returns TRUE if the specified [[inventory item]] is in the player's inventory (i.e. the item's [[OBJECT File (AGI)|room number]] equals 255). | [[Category:AGI Pages]] | ||
[[Category:AGI Pages to be Edited]] | |||
[[AGI Logic Commands by Name|Return to AGI Logic Commands by Name]] | |||
<div align="center"><span style="font-size: 22pt">Has</div> | |||
<br /> | |||
==<br /> Introduction == | |||
The '''has''' command returns TRUE if the specified [[Inventory Item (AGI)|inventory item]] is in the player's inventory (i.e. the item's [[OBJECT File (AGI)|room number]] equals 255). | |||
== Syntax == | == Syntax == | ||
| Line 12: | Line 21: | ||
The '''has''' command checks the [[OBJECT File (AGI)|room number]] value of item '''iA''' and returns true if it equals 255. This is basically a shortcut equivalent to the '''[[obj.in.room]]''' command if testing for room 255. | The '''has''' command checks the [[OBJECT File (AGI)|room number]] value of item '''iA''' and returns true if it equals 255. This is basically a shortcut equivalent to the '''[[obj.in.room]]''' command if testing for room 255. | ||
If an [[ | If an [[Inventory Item (AGI)|inventory item's]] [[OBJECT File (AGI)|room number]] is 255 it means the object has been 'picked up' and is in the player's inventory. | ||
This statement can be combined with the <code>NOT</code> operator to create a ‘not in inventory’ test. | This statement can be combined with the <code>NOT</code> operator to create a ‘not in inventory’ test. | ||
| Line 18: | Line 27: | ||
== Possible Errors == | == Possible Errors == | ||
If the [[inventory item]] is not valid (the number exceeds the total number of inventory items in the [[OBJECT]] | If the [[Inventory Item (AGI)|inventory item]] is not valid (the number exceeds the total number of inventory items in the [[OBJECT File (AGI)|OBJECT file]]), AGI will raise [[trappable error #23]]. | ||
== Example == | == Example == | ||
| Line 47: | Line 56: | ||
|} | |} | ||
== | ==<br /> References == | ||
<references /> | |||
==<br /> Related Links == | |||
[[Test Commands]] | * [[AGI Command Reference - Test Commands|Test Commands]] | ||
[[Inventory Item Commands]] | * [[AGI Command Reference - Inventory Item Management Commands|Inventory Item Commands]] | ||
* [[obj.in.room]] | |||
[[Category:Commands]] | <br /> | ||
[[AGI Logic Commands by Name#Commands|< AGI Logic Command Index]] | |||
| |||
[[Category:Commands]] | |||
[[Category:AGI Logic Commands]] | |||
Latest revision as of 16:51, 4 April 2025
Return to AGI Logic Commands by Name
Introduction
The has command returns TRUE if the specified inventory item is in the player's inventory (i.e. the item's room number equals 255).
Syntax
has(itm iA)
has("item")
Remarks
Test commands are only valid in an if statement.
The has command checks the room number value of item iA and returns true if it equals 255. This is basically a shortcut equivalent to the obj.in.room command if testing for room 255.
If an inventory item's room number is 255 it means the object has been 'picked up' and is in the player's inventory.
This statement can be combined with the NOT operator to create a ‘not in inventory’ test.
Possible Errors
If the inventory item is not valid (the number exceeds the total number of inventory items in the OBJECT file), AGI will raise trappable error #23.
Example
if(has(i12))
{
print("you already have item 12");
}
[ equivalent code:
v50 = 255;
if obj.in.room(i12, v50))
{
print("you already have item 12");
}Technical Information
| Required Interpreter Version: | Available in all AGI versions. |
| Byte-Code Value: | 9 (0x09 hex) |
References