Script Language: Predefined Functions and Properties: Inventory Management and Display


These scripts, defined in the file inventory.s are used to manipulate the player's inventory.

Each inventory item has an item type and a unique inventory item code. This code can be used to refer to a particular item in the inventory.

Properties


Functions




property SelectedObject

This object will be used as the source object when the user clicks on the screen. The most common use is to represent the currently selected inventory object.




function CountItems

Returns the number of items in the inventory.

Notes

This script is defined in the standard file inventory.s.




function TakeItem (type)

Adds a new item to the inventory.

Parameters

type Type of item to add.
Returns

Unique inventory item code.

Notes

This script is defined in the standard file inventory.s.

Example
takeItem(Walkto);
var thisKnife = takeItem(Knife);




function DropItem (type)

Drops an item from the inventory.

Parameters

type Item type or unique inventory code.
Notes

This script is defined in the standard file inventory.s.




function DropAllItems

Drops all inventory items (in the current bank).

Notes

This script is defined in the standard file inventory.s.




function SelectItem (type)

Chooses which item is currently selected. The selected item is the one whose image is used by the cursor, and that is used to trigger all events involving the mouse.

Parameters

type Item type or unique inventory code of item to select.
Notes

This script is defined in the standard file inventory.s.

Example
selectItem(Walkto);
selectItem(targetItem);




function HaveItem (type)

Tests if an item is in the inventory by returning the count of all items of the specified type.

Parameters

type Item type to count.
Returns

Number of items.

Notes

This script is defined in the standard file inventory.s.

Example
if haveItem(GoldKey) {
   "You unlock the door with the gold key."
   GoldDoorUnlocked = true;
}
if haveItem(LargeRock) > 3 {
   "I'm too heavy to ride the raft."
     "Unless I unload a few rocks first, I'll just sink."
}




function DeselectItem

Selects the cursor item, effectively "putting away" whichever item is currently selected, and sets the MouseSprite and MouseFrame to the DeafultMouseSprite and DefaultMouseFrame.

Returns

Returns true if an item is deselected, or false if there was no item to deselect.

Notes

This script is defined in the standard file inventory.s.