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 over
See Also: InventoryItem.GetName, GetLocationName
InventoryItem.GetName(string buffer)Fills in BUFFER with the name of the inventory item. This is the name which the item is given under the Game tab, Inventory mode of the AGS Editor.
Example:
string buffer; player.ActiveInventory.GetName(buffer);will pass the inventory item’s name to the buffer.
See Also: InventoryItem.GetAtScreenXY, InventoryItem.Graphic, GetLocationName, InventoryItem.SetName
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 GetPropertyText 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.GetPropertyText
InventoryItem.GetPropertyText(string property, string buffer)Returns the custom property setting PROPERTY for the inventory item.
This command works with Text properties only. The property's text will be copied into the BUFFER that you pass to this command.
Use the equivalent GetProperty function to get a non-text property.
Example:
string buffer; inventory[2].GetPropertyText("Description", buffer); Display("Inv item 2's description: %s", buffer);will retrieve inv item 2's "description" property into the buffer, then display it.
See Also: InventoryItem.GetProperty
InventoryItem.IsInteractionAvailable(CursorMode)Checks whether there is an interaction defined for activating the inventory item in cursor mode MODE.
This function is very similar to RunInteraction, except that rather than carry out any interactions it encounters, it simply returns 1 if something would have happened, or 0 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(eModeLook) == 0) Display("looking at this item would not do anything.");See Also: IsInteractionAvailable, InventoryItem.RunInteraction
InventoryItem.RunInteraction(CursorMode)Processes the interaction list 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 interaction 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
InventoryItem.SetName(string name)Changes the inventory item's name to NAME. This is useful 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 pass is longer than this, it will be truncated.
Example:
inventory[10].SetName("Full cup of water");will change inventory item 10's name to "Full cup of water".
See Also: InventoryItem.GetName, InventoryItem.Graphic
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.GetName
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
Browser Based Help. Published by chm2web software. |