Inventory
Items are kept in a master items script. This could realistically be scene-dependent or cut into multiple item scripts. They are in parsed/loaded from parser/input/en/items.html.
The following is an item block in the item's script. label is the name of the item to be called and jump script game diverts the script back to the main game.
label nameditem
Nao: Woah, a named item!
jump script game
Call item from client.
(game as GameModule).playItemScript("nameditem");
The item's label will always be the name of the item in lower case with no spaces. The code can be seen as followed
"Named Item".toLowerCase().replaceAll(" ", "");
For YTTT, this is implemented within the inventory container class.
interface InventoryItem {
name: string; // What the item shows up as in the inventory
onclick?: CallbackFunction;
}
class InventoryContainer extends UIContainer {
constructor() {
const inventory: Array<InventoryItem>;
inventory.push({
name: "Named Item",
onclick: () => {
this.game.playItemScript("nameditem");
this.hide();
},
});
this.instantiate();
this.display();
}
}