Skip to reading
BASIC Scripting

Read rooms and count inventory

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

BASIC IN YOUR GAME

Is the player carrying the battery, or does the battery merely exist in your database? Those are two different questions. InventoryCount tells you what the character actually has.

Code example
FUNCTION Run()
    DIM before = InventoryCount("cell")
    AWAIT AddInventory({"itemId": "cell", "count": 1})
    RETURN InventoryCount("cell") - before
END FUNCTION

Here cell is an existing inventory item ID. The first line counts what the player already has. After the action, the difference is 1, whether the count started at zero or higher. Supply the optional character ID to InventoryCount when checking another character.

Code example
FUNCTION Run()
    RETURN rooms.lab.name
END FUNCTION

Read this as “the name field on the room whose ID is lab.” In the preview it returned 01 · Blockout Lab. Use the actual ID from your own room record.

Other record families include characters, objects, triggers, guis, dialogues, quests, objectives, assets, cameras and spawns. After typing the record name and a dot, use the editor’s completions to look for fields available on that record.

Page 28 of 86Permalink
Go to page