Inventory
What an entity is carrying: keys, potions, the parts of a machine, gold, blocks. A Pickup with an Pickup.Item puts things in the inventory of whoever collects it (adding one if they don’t have one); locked Doors and Switches use up its keys. A Counter with an Counter.Item shows how many there are. Items are the one idea every genre shares (see Items): what a recipe takes, a strategy unit or a card costs or a shop’s pickup sells for is paid from it, and with ForTeam it holds a whole team’s.
It’s saved with the scene, so it rewinds with everything else and you can start a playtest holding a key; with SaveAs it’s kept in the save data too, from one run (and one scene) to the next.
Needed by: Crafting, Hotbar, InventoryBar
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
items: lines of text: an array of strings, or one string with line breaks = []. What it holds, one kind per row: a name and how many, e.g. “Key 2” (just “Key” is one). (Items and how many of each, one a line: the item’s name then how many, e.g. “Key 2” (just “Key” is one). The Inspector lists them a row each, the item picked from those the game gives.) (Field: its own editor: Item Counts.)
Using Items
Section titled “Using Items”itemUses: lines of text: an array of strings, or one string with line breaks = []. What its items do when they’re used, one per line: the item, a colon, and what it does, several separated by commas: “heal 3” gives back hit points, “spawn Explosion” spawns a prefab where it stands, “send Teleport” sends a message (with this entity as its data). E.g. “Potion: heal 3”, “Bomb: spawn Explosion, send Boom”. Using one takes it out; a potion that only heals isn’t used up at full health. (What items do when used, one item a line: its name, a colon, then what it does, separated by commas: “heal 3” (hit points), “spawn Explosion” (a prefab) or “send Teleport” (a message), e.g. “Bomb: spawn Explosion, send Boom”. The Inspector lists them, picking the item, prefab and message.) (Field: its own editor: Item Uses.)numberKeys: true or false = true. The number keys use what it holds: 1 the first item it has with a use (in the order it got them), 2 the second, up to 9. (Field: on or off.)useSound: text = null. A sound played as an item is used, e.g. “Sounds/drink.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
Saving
Section titled “Saving”saveAs: text = null. Keeps what it holds in the game’s save data under this name, e.g. “Items”, so it’s still there the next time the game runs, and an inventory saved as the same name in the next scene starts with it (a player walking from room to room). Empty keeps nothing. Game → Clear Save Data forgets it while you test. (Names a name in the save data: this entity’s own, which other fields can name.) (Field: a name.)
forTeam: text = null. Holds a team’s items, e.g. “Player”: anything on that team (see Teams) without an inventory of its own collects into it and pays from it, so a platformer hero’s coins buy a strategy army or pay for cards. Empty holds only its own entity’s. (Names a team.) (Field: a name.)loaded: true or false = false. Set by the game once it has taken what it holds from the save data, so a rewind doesn’t do it again. Leave it be. (Field: on or off.)
Actions
Section titled “Actions”What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).
AddItems(done with a name, its items: a trigger’s with). Puts in the items listed, e.g. “Gold 50, Key”: something won, bought or found.TakeItems(done with a name, its items: a trigger’s with). Takes out the items listed, e.g. “Gold 50”, if it holds them all; otherwise takes nothing.
Outputs
Section titled “Outputs”What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.
Count(a whole number, read by a item after a colon, e.g. “Count:Key”). How many of item it holds (names ignore case). Read as “Count:Key”.
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
usable: lines of text: an array of strings, or one string with line breaks. The items it holds that have a use (see ItemUses), in the order it got them: what the number keys use.version: a whole number. A number that goes up whenever what it holds changes, so what shows it redraws only then.
Scripts use it as Inventory: its methods, events and values that aren’t saved with the scene.