static InventoryItem* InventoryItem.GetAtScreenXY(int x, int y)Returns the inventory item at SCREEN co-ordinates (X,Y). Note that this only detects inventory items on custom Inventory windows (that are switched on when this function is called), and is intended to allow you to do Verb Coin style GUIs and so on.
If there is no inventory item there, or if invalid co-ordinates are specified, returns null.
NOTE: The co-ordinates are SCREEN co-ordinates, NOT ROOM co-ordinates. This means that with a scrolling room, the co-ordinates you pass are relative to the screen's current position, and NOT absolute room co-ordinates. This means that this function is suitable for use with the mouse cursor position variables.
Example:
InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (item == null) {
Display("No inventory item at the mouse co-ordinates");
}
else {
Display("Inventory item number %d at the mouse.", item.ID);
}
will display the number of the inv item that the mouse is overSee Also: InventoryItem.Name, Game.GetLocationName
InventoryItem.GetProperty(string property)Returns the custom property setting PROPERTY for the inventory item.
This command works with Number properties (it returns the number), and with Boolean properties (returns 1 if the box was checked, 0 if not).
Use the equivalent GetTextProperty function to get a text property.
Example:
if (inventory[1].GetProperty("Value") > 200)
Display("Inventory item 1's value is over 200!");
will print the message if inventory item 1 has its "Value" property set to more than 200.See Also: InventoryItem.GetTextProperty
String InventoryItem.GetTextProperty(string property)Returns the custom property setting PROPERTY for the inventory item.
This command works with Text properties only. The property's text will be returned from this function.
Use the equivalent GetProperty function to get a non-text property.
Example:
String description = inventory[2].GetTextProperty("Description");
Display("Inv item 2's description: %s", description);
will retrieve inv item 2's "description" property and display it.See Also: InventoryItem.GetProperty
InventoryItem.IsInteractionAvailable(CursorMode)Checks whether there is an event handler defined for activating the inventory item in cursor mode MODE.
This function is very similar to RunInteraction, except that rather than run the event handler script function, it simply returns true if something would have happened, or false if unhandled_event would have been run.
This is useful for enabling options on a verb-coin style GUI, for example.
Example:
if (iKeyring.IsInteractionAvailable(eModeLookat) == 0)
Display("looking at this item would not do anything.");
See Also: IsInteractionAvailable,
InventoryItem.RunInteraction
InventoryItem.RunInteraction(CursorMode)Runs the event handler as if the player had clicked the mouse on the inventory item, using the specified cursor mode.
Example:
if (button == eMouseLeftInv) inventory[game.inv_activated].RunInteraction(mouse.Mode);will run the inventory event handler for the current cursor mode when the player clicks on the item (Handle Inv Clicks needs to be enabled for this to work)
See Also: InventoryItem.IsInteractionAvailable, ProcessClick, Character.RunInteraction
int InventoryItem.GraphicGets/sets the sprite slot number of the inventory item. You could use this with the Object.Graphic property as a means of the player 'dropping' an inventory item, or it may be useful if you want to do a Raw Drawn inventory window.
Example:
int slot = player.ActiveInventory.Graphic;will place the sprite number of the player's current inventory item into slot.
See Also: InventoryItem.GetAtScreenXY, InventoryItem.Name
readonly int InventoryItem.IDGets the inventory item's ID number. This is the item's number from the editor, and is useful with commands such as Character.AddInventory which require an inventory number to add.
Example:
AddInventory(EGO, iShovel.ID);uses the obsolete AddInventory command to add the shovel to EGO's inventory
See Also: Character.AddInventory, Character.LoseInventory
String InventoryItem.Name;Gets/sets the name of the inventory item. This is the name which is initially set under the Game tab, Inventory mode of the AGS Editor.
You can change this property if for example you want to change a 'bowl' to a 'bowl with water in' but want to use the same inventory item for it.
Note that the maximum length for the name of an inventory item is 24 characters - if the name you set is longer than this, it will be truncated.
Example:
Display("Active inventory: %s", player.ActiveInventory.Name);
will display the name of the player's current inventory item.See Also: InventoryItem.GetAtScreenXY, InventoryItem.Graphic, Game.GetLocationName