Contents Up Previous Next

Inventory functions

AddInventory
GetInvAt
GetInvGraphic
GetInvName
GetInvProperty
GetInvPropertyText
InventoryScreen
IsInventoryInteractionAvailable
LoseInventory
RunInventoryInteraction
SetActiveInventory
SetInvDimensions
SetInvItemName
SetInvItemPic
UpdateInventory


AddInventory

AddInventory (int what)
Adds inventory index WHAT to the current player character's inventory. This has the same effect as doing character[EGO].inv[WHAT]+=1; however, it will add the inventory to the current player character and also update the inventory window.

Example:

AddInventory(10);
will give to the player character the inventory item numbered 10.

See Also: LoseInventory


GetInvAt

GetInvAt (int x, int y)
Returns the number of 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 -1.

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:

string buffer;
StrFormat (buffer, "The mouse is over inventory item %d", GetInvAt (mouse.x, mouse.y));
SetLabelText (1, 1, buffer);
will print the number of the inv item that the mouse is over to label 1 on GUI 1.

See Also: GetInvName, GetLocationName


GetInvGraphic

GetInvGraphic (int item)
Returns the sprite slot number of inventory item index ITEM. You could use this with SetObjectGraphic 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 = GetInvGraphic (player.activeinv);
will place the sprite number of the player's current inventory number into slot.

See Also: GetInvAt, GetInvName, SetInvItemPic


GetInvName

GetInvName (int item, string buffer)
Fills in BUFFER with the name of inventory item index ITEM. This is the name which the item is given under the Game tab, Inventory mode of the Room Editor.

Example:

string buffer;
GetInvName (player.activeinv, buffer);
will pass the inventory item’s name to the buffer.

See Also: GetInvAt, GetInvGraphic, GetLocationName, SetInvItemName


GetInvProperty

GetInvProperty (int item, string property)
Returns the custom property setting of inventory ITEM for PROPERTY.

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 (GetInvProperty(1, "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: GetInvPropertyText


GetInvPropertyText

GetInvPropertyText (int item, string property, string buffer)
Returns the custom property setting of inventory ITEM for PROPERTY.

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;
GetInvPropertyText(2, "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: GetInvProperty


InventoryScreen

InventoryScreen ()
Brings up the Sierra-style inventory window which allows the player to select and manipulate inventory items. If they select one, the cursor mode will be set to inventory-use (mode 4), and character[EGO].activeinv will be set to the inventory item selected.

NOTE: This function does not actually bring up the window immediately; instead, it will show the window when the current script function finishes executing.

NOTE: If the player has no inventory items, global message 996 will be displayed.


IsInventoryInteractionAvailable

IsInventoryInteractionAvailable (int item, int mode)
Checks whether there is an interaction defined for activating inventory item ITEM in cursor mode MODE.

This function is very similar to RunInventoryInteraction, 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 (IsInventoryInteractionAvailable(3, MODE_LOOK) == 0)
  Display("looking at this item would not do anything.");
See Also: IsInteractionAvailable, RunInventoryInteraction


LoseInventory

LoseInventory (int what)
Removes inventory item WHAT from the current player character's inventory. If they do not have the item, nothing happens.

Example:

LoseInventory(10);
will make the player character lose the inventory item numbered 10 in the inventory tab

See Also: AddInventory


RunInventoryInteraction

RunInventoryInteraction (int item, int mode)
Processes the interaction list as if the player had clicked the mouse on inventory item ITEM in cursor mode MODE. MODE is one of the MODE_* constants listed in the ProcessClick description.

Example:

if (button == LEFTINV)
  RunInventoryInteraction(game.inv_activated, GetCursorMode());
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: IsInventoryInteractionAvailable, ProcessClick, RunCharacterInteraction


SetActiveInventory

SetActiveInventory (int inv_item)
Sets the current active inventory item for the current player character to INV_ITEM. This function changes the player.activeinv variable, and also sets up the mouse cursor as necessary. To deselect the current inventory, pass INV_ITEM as -1.

Example:

SetActiveInventory(10);
will make the inventory item 10 active (before you use it make sure that the player has the inventory item )


SetInvDimensions

SetInvDimensions (int width, int height)
Allows you to change the default width and height of the inventory item picture slots used by the Lucasarts-style inventory window. By default, the LEC inv window is made up of 40x22 pixel cells, but if all your inventory item pictures are bigger or smaller than this, you can use this function to adjust them.

Example:

SetInvDimensions(60,30);
if your inventory graphics are 60x30 pixels or smaller.


SetInvItemName

SetInvItemName(int inv, string name)
Changes inventory item INV'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:

SetInvItemName(10, "Full cup of water");
will change inventory item 10's name to "Full cup of water".

See Also: GetInvName, SetInvItemPic


SetInvItemPic

SetInvItemPic (int inv, int sprite_slot)
Changes inventory item INV's graphic to be slot number SPRITE_SLOT from the Sprite Manager. This allows you to dynamically adjust an item's picture in the inventory window during the game.

Example:

SetInvItemPic(10,120);
will change the number 10 inventory item’s graphic, to the picture imported in slot 120 (sprite manager’s slot).

See Also: GetInvGraphic, SetInvItemName


UpdateInventory

UpdateInventory ()
Updates the player's inventory display. If you add or remove inventory items manually (ie. by using the character[].inv[] variables rather than the AddInventory/LoseInventory functions), the display may not get updated. In this case, after making your changes, call this function to update what is displayed to the player.

See Also: AddInventory, LoseInventory