Wax

Items and inventories

What a kind of item is, and what an inventory or a character holds.

The Explorer searches everything on this page, and the classes of the game too.

game.Items

The kinds of item the game has, and the facts of each. Nothing is read until you ask, and what was read is kept. An item is named by its row in D_ItemsStatic, such as "Wood" or "Stone_Pickaxe". Letter case, spaces, underscores and hyphens do not matter, so "stone pickaxe" names the same item.

Type name: WaxItems.

Open in the Explorer

game.Items:Get(item)

The facts of one kind of item. A name the game does not have raises an error that suggests the nearest names, so ask Has first when the name may be wrong. The first time an item is asked for, up to three rows of the game's tables are read. After that it costs nothing, until a mod changes those tables or the game makes them again.

game.Items:Get(item: string|WaxItemStack|WaxItemFacts): WaxItemFacts
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFactsThe item's name, or a record that List or Get gave.

Returns WaxItemFacts

Open in the Explorer

game.Items:Has(name)

True when the game has an item of this name.

game.Items:Has(name: string): boolean
ParameterType
namestring

Returns boolean

Open in the Explorer

game.Items:Share(total, item, stations)

Deals total of an item out over the stations of one kind, as evenly as their room allows, so they all work at once: each gets up to the share that brings it level with the others, one that already holds more than its share gets nothing until the rest catch up, and what the even split leaves over goes to the first (the nearest, when the list is nearest first). Pure sums: nothing is moved. The stack size comes from Get.

game.Items:Share(total: integer, item: string|WaxItemStack, stations: WaxShareStation[]): table<integer, integer>, integer
ParameterTypeDescription
totalintegerHow many there are to deal out.
itemstring | WaxItemStack
stationsWaxShareStation[]

Returns

  • table<integer, integer> (given) How many each station gets, by its index in the list; stations that get nothing are left out.
  • integer (left) What no station had room for.

Open in the Explorer

game.Items:GetNames()

The name of every item, spelled and ordered as the game has them.

game.Items:GetNames(): string[]

Returns string[]

Open in the Explorer

game.Items:Find(text)

The names of the items whose name contains the text: first the ones that begin with it, then the others, each group sorted. Once Load has run, an item also matches when the name the game shows for it contains the text. "iron" then finds Metal_Ore, which the game shows as Iron Ore. Letter case, spaces, underscores and hyphens do not matter. It goes through every item, so call it when the player types something, not every frame.

game.Items:Find(text: string): string[]
ParameterType
textstring

Returns string[]

Open in the Explorer

game.Items:Load()

Reads the name the game shows for every item, so that Find matches those names too. It only works inside a task: it reads within a millisecond a frame and returns when all are read. Rows another mod has read already are not read again. When a mod changes the item tables, or the game makes them again, Find goes by item names alone until Load has run again.

game.Items:Load(): integer

Returns integer (count) How many items have a shown name.

Open in the Explorer

game.Containers

The structures around the player that hold items: chests, cupboards, pouches, benches, furnaces and the like, kept by a list that follows the world (nothing is looked for until the first call, and after it a structure joins the moment it appears and leaves when it goes).

Type name: WaxContainers.

Open in the Explorer

SignalHandler receivesDescription
ChangednothingFires when a structure appeared or went away, and once on a map change.

game.Containers:Nearby(range?, options?)

The structures within range metres that can hold items, nearest first.

game.Containers:Nearby(range?: number, options?: WaxNearbyOptions): WaxNearbyContainer[]
ParameterTypeDescription
range (optional)numberMetres. 30 when omitted.
options (optional)WaxNearbyOptions

Returns WaxNearbyContainer[]

Open in the Explorer

game.Containers:Around(place, range?, options?)

The same list measured from a place in the game's own units (a station, a build site, a spot on a server that has no player to measure from), nearest first.

game.Containers:Around(place: { X: number, Y: number, Z: number }, range?: number, options?: WaxNearbyOptions): WaxContainer[]
ParameterTypeDescription
place{ X: number, Y: number, Z: number }
range (optional)numberMetres. 30 when omitted.
options (optional)WaxNearbyOptions

Returns WaxContainer[]

Open in the Explorer

game.Containers:Totals(inventory, options?)

What an inventory holds, by item row in lower case: { wood = 140, fiber = 12 }. One pass over its stacks, kept until the inventory's slots used or items held change, so asking every frame costs two cheap reads at most.

game.Containers:Totals(inventory: WaxInventory|any, options?: { stale?: boolean }): table<string, integer>
ParameterTypeDescription
inventoryWaxInventory | anyA Wax inventory or the engine's own object.
options (optional){ stale?: boolean }stale = true answers the last pass with no read at all once one exists, for a path that runs many times a frame while something else keeps it fresh.

Returns table<string, integer>

Open in the Explorer

game.Containers:Held(item, range?, options?)

How many of an item the structures within range hold, storage, inputs and fuel together.

game.Containers:Held(item: string|WaxItemStack, range?: number, options?: WaxHeldOptions): integer
ParameterTypeDescription
itemstring | WaxItemStackThe item row, such as "Wood".
range (optional)numberMetres. 30 when omitted.
options (optional)WaxHeldOptions

Returns integer

Open in the Explorer

game.Containers:Kinds(range?, options?)

The kinds of structure in range and how many of each, by name.

game.Containers:Kinds(range?: number, options?: WaxNearbyOptions): WaxContainerKind[]
ParameterType
range (optional)number
options (optional)WaxNearbyOptions

Returns WaxContainerKind[]

Open in the Explorer

game.Containers:Accepted(row)

What a station of this item row can process: every input of the recipes in its recipe set, as { [name in lower case] = the game's spelling }, read from D_ItemsStatic, D_Processing and D_ProcessorRecipes once a set. The first read of the recipes pauses the task it is in; outside a task it answers nil and "reading" until a task has read them.

game.Containers:Accepted(row: string): table<string, string>?, string?
ParameterTypeDescription
rowstringA structure's item row, such as "Kit_Stone_Furnace".

Returns

  • table<string, string>? (accepted) Nil for a structure that is no station, or while the recipes are still being read.
  • string? (why) "not a station" or "reading"; the recipe set's name when the first value is given.

Open in the Explorer

game.Containers:Count()

How many structures that hold items the list knows of, in the whole world.

game.Containers:Count(): integer

Returns integer

Open in the Explorer

WaxItemStack

One stack in a slot of an inventory. Its fields are plain values, and changing them changes nothing in the game. Equip and Activate are functions: they tell the game to put this stack in a character's hand.

You get one from inventory:List, inventory:Slot, inventory:Where, playerItems:List. Below, stack stands for one of these.

Open in the Explorer

PropertyTypeDescription
ItemstringThe item's name as the game spells it. The game's own files do not always use the same letter case, so compare two names without it, or ask Count, Has or Where.
CountintegerHow many are in the stack. 1 for an item the game keeps no stack number for.
SlotintegerThe slot it is in, counted from 1. The game's own functions count from 0: their Location is Slot - 1.
Durabilityinteger?How much durability it has left. nil for an item the game keeps none for.
Propertiestable<string|integer, integer>?Every number the game keeps for this stack, under the game's own name for it (EDynamicItemProperties): ItemableStack, Durability, GunCurrentMagSize, CurrentAmmoType, MillijoulesRemaining, TransmutableUnits, Fillable_StoredUnits, Fillable_Type, Decayable_CurrentSpoilTime and the others. One this version of Wax has no name for is under its number. nil when the game keeps none.
Inventorystring?Which inventory of the character it is in: "Backpack", "Hotbar", "Equipment", "Suit", "Upgrades" or "Vision". Only what a character's List and HeldItem give has it.

stack:Equip()

Puts this stack into the character's hand. The game focuses this slot of its inventory. The location the game uses is Slot - 1. game.Me.Equipped follows on its next look. A hotbar key does the same kind of change, and Equipped follows that too. The stack has to be one that Slot, List, Where or HeldItem gave.

stack:Equip()

Returns nothing.

Open in the Explorer

stack:Activate(use?)

Puts this stack into the character's hand, then fires game.Me.Activated with the stack and use. With a use name, the game also runs that row of D_Uses. "Consume" and "Place" are two such names. A name the game does not have raises an error. With no name, the stack is in the hand and Activated fires with nil. A tool's swing is the game's fire button.

stack:Activate(use?: string)
ParameterTypeDescription
use (optional)stringThe name of a row of D_Uses. Leave it out to put the stack in the hand.

Returns nothing.

Open in the Explorer

WaxNearbyContainer

A structure near the player that holds items, as game.Containers:Nearby gives it.

You get one from game.Containers:Nearby. Below, nearbyContainer stands for one of these.

Open in the Explorer

PropertyTypeDescription
RowstringIts item in D_ItemsStatic, such as "Kit_Stone_Furnace" or "Storage_Metal_Cupboard".
NamestringThe name the game shows for it.
Kind"storage" | "station" | "cargo"A station has an input inventory a processor works from; a cargo animal is a tamed creature with a cargo inventory (its Row is "cargo:<set-up row>", its Name "Cargo: <kind>"); everything else is storage.
DistancenumberMetres from the player.
ActorWaxInstanceThe structure itself.
InventoriesWaxInventory[]Its inventories that take items: not the fuel slot, not a remove-only or client-side one.
FuelWaxInventory[]Its fuel inventories.
InputsWaxInventory?A station's input inventory.

nearbyContainer:Accepts(item)

True when a stash or a pull of the item may go into it: for a station, when one of the recipes of its recipe set takes the item; for storage, when it has an inventory that takes items.

nearbyContainer:Accepts(item: string|WaxItemStack): boolean
ParameterType
itemstring | WaxItemStack

Returns boolean

Open in the Explorer

nearbyContainer:OwnedBy(state)

For a cargo animal, true when it belongs to the player whose PlayerState is given (the game's own IsMountOwner); true for every structure.

nearbyContainer:OwnedBy(state: any): boolean
ParameterType
stateany

Returns boolean

Open in the Explorer

WaxInventory

What Wax adds to every inventory: every Instance whose class is Inventory. A player's character has six of them, and other things that hold items have their own. Wax keeps a copy of an inventory that is asked about, so asking often costs little. It looks at the inventory again at most four times a second. When the weight or the number of slots is not what it was, every slot is read again. Otherwise a few slots are read in turn, so that all of them are read again within two seconds while you keep asking. An inventory that was not asked about for two seconds is read whole the next time. The game works a weight out a moment after the items change, so a new stack or a used-up one shows about a quarter of a second later, and what changes without the weight changing, such as durability or a stack moved to another slot, within two seconds. Refresh reads it all at once. Where the game itself tells Wax of a slot it changed, the copy follows at that moment and none of that waiting applies. That was seen for the inventories of a player's character on the host of a session. For a chest or a bench, and as a guest in someone else's game, it has not been tried, and there the looking above is what keeps the copy right. A field is nil, and a function raises an error that says so, when the game no longer keeps its inventories the way Wax reads them.

Below, inventory stands for one of these.

Open in the Explorer

PropertyTypeDescription
Kindstring?What kind of inventory the game says it is: its row of D_InventoryInfo, such as "Backpack", "Quickbar" or "Equipment". It is asked of the game each time it is read.
Sizeinteger?How many slots it has. #inventory is this number.
Usedinteger?How many of its slots hold something.
Weightnumber?What everything in it weighs, in kilograms. It is asked of the game each time it is read.
SignalHandler receivesDescription
ItemAddeditem: string, amount: integer, stack: WaxItemStack?Fires when the inventory holds more of an item than a frame before: the item's name as the game spells it, how many more, and a stack it went onto. It is told by the game, for every slot the game says it changed, so it only fires where the game tells of an inventory: see above. A stack that moves to another slot of the same inventory within a frame is not added. Connecting reads the inventory whole once.
ItemRemoveditem: string, amount: integer, stack: WaxItemStack?Fires when the inventory holds fewer of an item than a frame before: the item, how many fewer, and a stack it came out of as that was before.
ItemChangedstack: WaxItemStack?, previous: WaxItemStack?Fires for every slot that holds something else than a frame before: what it holds now, nil for nothing, and what it held. A tool that wore and a stack that moved are changes too. A spoil timer that only counts down is not. After a map change the handlers of all three are disconnected.

inventory:List()

Every stack in the inventory, in the order of its slots.

inventory:List(): WaxItemStack[]

Returns WaxItemStack[]

Open in the Explorer

inventory:Slot(slot)

What one slot holds, or nil when it is empty. Slots are counted from 1 to Size, and another number raises an error. inventory[n] is this. An empty slot is nil, so a loop from 1 to #inventory reaches every slot.

inventory:Slot(slot: integer): WaxItemStack?
ParameterType
slotinteger

Returns WaxItemStack?

Open in the Explorer

inventory:Count(item)

How many of an item the inventory holds, over all its stacks. Only its own slots are counted, not what an item in it holds inside. An item is named as game.Items names it, and a name the game does not have raises an error that suggests the nearest names.

inventory:Count(item: string|WaxItemStack|WaxItemFacts): integer
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFactsThe item's name, or a record that List or game.Items:Get gave.

Returns integer

Open in the Explorer

inventory:Has(item, count?)

True when the inventory holds at least count of an item. One when count is omitted.

inventory:Has(item: string|WaxItemStack|WaxItemFacts, count?: number): boolean
ParameterType
itemstring | WaxItemStack | WaxItemFacts
count (optional)number

Returns boolean

Open in the Explorer

inventory:Where(item)

The stacks of an item in the inventory, in the order of their slots. An empty list when it holds none.

inventory:Where(item: string|WaxItemStack|WaxItemFacts): WaxItemStack[]
ParameterType
itemstring | WaxItemStack | WaxItemFacts

Returns WaxItemStack[]

Open in the Explorer

inventory:Refresh()

Reads every slot again now. A whole backpack took the game between half a millisecond and a millisecond and a half when it was measured, so use it when something has to be exact at once, not every frame.

inventory:Refresh()

Returns nothing.

Open in the Explorer

inventory:Give(item, count?)

Puts items into the inventory. They go onto the stacks of that item first, then into empty slots that the game says take that kind of item, a full stack to a slot. What does not fit is not given, and nothing is dropped on the ground. A tool comes as the game makes a new one, with its full durability. Count, Has and List follow in the same frame, the weight a moment later. It has been tried on a player's backpack.

inventory:Give(item: string|WaxItemStack|WaxItemFacts, count?: integer): integer, string?
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFactsThe item's name, or a record that List or game.Items:Get gave. A name the game does not have raises an error that suggests the nearest names.
count (optional)integerHow many, from 1 to 100000. One when omitted.

Returns

  • integer (given) How many went in.
  • string? (why) Why not all of them, in plain words, when fewer went in: "there was no room for 3 of the 10".

Open in the Explorer

inventory:Take(item, count?)

Takes items out of the inventory. They are gone, not dropped, and the last stack of the item goes first. It has been tried on a player's backpack and hotbar.

inventory:Take(item: string|WaxItemStack|WaxItemFacts, count?: integer): integer, string?
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFacts
count (optional)integerHow many, from 1 to 100000. One when omitted.

Returns

  • integer (taken) How many were taken.
  • string? (why) Says how many there were, when there were fewer than asked for.

Open in the Explorer

inventory:Resize(slots)

Gives the inventory this many slots. Slots are added and taken at its end. A slot that holds something is never taken, nor any slot before it: the inventory then keeps as many as it needs, and the second value says so. Size, List and the others follow in the same frame. It lasts as long as the inventory does: one the game makes anew, as on a map change, has the number of its row of D_InventoryInfo again. It has been tried on the station's loadout, from 15 to 50 slots and back.

inventory:Resize(slots: integer): integer, string?
ParameterTypeDescription
slotsintegerHow many slots it should have, from 1 to 500.

Returns

  • integer (size) How many it has now.
  • string? (why) Why not what was asked, in plain words: "slot 31 holds something, so 31 slots stay".

Open in the Explorer

inventory:Push(item, target)

Every stack of an item in this inventory goes into another, by the game's own "transfer all of a type": the call its own Transfer Like button makes, so it works in someone else's session as well. The stacks there are topped up first, then free slots are filled. Inside a task it waits for the game, up to 2.5 seconds, and answers how many went; outside a task it answers nil and "asked" at once.

inventory:Push(item: string|WaxItemStack|WaxItemFacts, target: Inventory|WaxInventory): integer?, string?
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFacts
targetInventory | WaxInventoryThe inventory it goes into.

Returns

  • integer? (moved) How many went. 0 when nothing did.
  • string? (why) "asked" outside a task, else why nothing went.

Open in the Explorer

inventory:Pull(item, source)

The same the other way: every stack of the item in source comes into this inventory.

inventory:Pull(item: string|WaxItemStack|WaxItemFacts, source: Inventory|WaxInventory): integer?, string?
ParameterType
itemstring | WaxItemStack | WaxItemFacts
sourceInventory | WaxInventory

Returns

  • integer? (moved)
  • string? (why)

Open in the Explorer

inventory:Move(slot, target, amount?)

Some of one stack to another inventory, by the game's own "shift": onto a stack of the same item there with room, else into an empty slot. Inside a task it waits for the game and answers how many went; outside a task nil and "asked".

inventory:Move(slot: integer, target: Inventory|WaxInventory, amount?: integer): integer?, string?
ParameterTypeDescription
slotintegerThe slot of this inventory the stack is in, counted from 1.
targetInventory | WaxInventory
amount (optional)integerHow many of the stack. The whole stack when omitted. More than the room there is cut down.

Returns

  • integer? (moved)
  • string? (why)

Open in the Explorer

WaxPlayerItems

What Wax adds to a player's character for the things it carries: every Instance whose class is IcarusPlayerCharacter or is built on it, and game.Me. Each inventory is an Instance of the game's Inventory with what WaxInventory lists, and is nil when the character has no such inventory, as the character in the station has no backpack. An inventory Wax cannot read is left out of Count, Has and List.

Below, playerItems stands for one of these.

Open in the Explorer

PropertyTypeDescription
BackpackInventory | WaxInventory?The character's backpack: its BackpackInventory.
InventoryInventory | WaxInventory?The character's backpack, the same value as Backpack. On a creature, Inventory stays the inventory the game keeps on it.
HotbarInventory | WaxInventory?The character's hotbar: its QuickbarInventory. hotbar[n] is hotbar:Slot(n), and #hotbar is how many slots it has. An empty slot is nil, so count from 1 to #hotbar to see every slot.
ShipInventoryInventory | WaxInventory?The cargo of the dropship assigned to this character, the hold the game calls DropShip_Equipment. nil while this character has no assigned dropship, as on the station. Count, Has and List on the character count the six inventories it carries; ask the ship with its own. Wax looks the ship up at most once a second. The hold the game calls Dropship_RemoveOnly is a different inventory.
EquipmentInventory | WaxInventory?What the character wears: its EquipmentInventory.
SuitInventory | WaxInventory?The character's EnvirosuitInventory.
UpgradesInventory | WaxInventory?The character's UpgradeInventory.
VisionInventory | WaxInventory?The character's VisionInventory.
HotbarSlotinteger?The slot of the hotbar the game says is in hand, counted from 1. The keys 1 to 9 and 0 are the slots 1 to 10, the box the game shows with G is slot 11, and with bare hands the game names slot 12. nil when the game names none, as it does for a moment after the item in hand is used up.
HeldItemWaxItemStack?What sits in that slot of the hotbar, or nil when it is empty. With bare hands it is the game's own item Player_Fist. It is as fresh as the hotbar's copy: see WaxInventory.

playerItems:Count(item)

How many of an item the character carries, over those six inventories.

playerItems:Count(item: string|WaxItemStack|WaxItemFacts): integer
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFactsThe item's name, or a record that List or game.Items:Get gave.

Returns integer

Open in the Explorer

playerItems:Has(item, count?)

True when the character carries at least count of an item. One when count is omitted.

playerItems:Has(item: string|WaxItemStack|WaxItemFacts, count?: number): boolean
ParameterType
itemstring | WaxItemStack | WaxItemFacts
count (optional)number

Returns boolean

Open in the Explorer

playerItems:List()

Every stack the character carries: the backpack's first, then the hotbar's, what it wears, and the other three, each in the order of its slots. Each record says in Inventory which one it is in.

playerItems:List(): WaxItemStack[]

Returns WaxItemStack[]

Open in the Explorer

playerItems:Give(item, count?)

Gives the character items into its backpack, as the backpack's own Give does. What does not fit in the backpack is not given: nothing goes to the hotbar and nothing is dropped.

playerItems:Give(item: string|WaxItemStack|WaxItemFacts, count?: integer): integer, string?
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFacts
count (optional)integerHow many, from 1 to 100000. One when omitted.

Returns

  • integer (given) How many went in.
  • string? (why) Why not all of them, when fewer went in.

Open in the Explorer

playerItems:Take(item, count?)

Takes items away from the character: out of its backpack first, then out of its hotbar. What it wears and what its other inventories hold is left alone. Take from one of those with the inventory's own Take.

playerItems:Take(item: string|WaxItemStack|WaxItemFacts, count?: integer): integer, string?
ParameterTypeDescription
itemstring | WaxItemStack | WaxItemFacts
count (optional)integerHow many, from 1 to 100000. One when omitted.

Returns

  • integer (taken) How many were taken.
  • string? (why) Says how many there were, when there were fewer than asked for.

Open in the Explorer

WaxItemFacts

What a kind of item is, from the game's own tables. The table is yours: changing it changes nothing in the game.

Returned by game.Items:Get. Used by game.Items:Get, inventory:Count, inventory:Has, inventory:Where, inventory:Give, inventory:Take, inventory:Push, inventory:Pull and others.

Open in the Explorer

FieldTypeDescription
NamestringThe item's name: its row in D_ItemsStatic, spelled as the game spells it.
DisplayNamestringThe name the game shows players, in the language the game was showing when it was read. The item's own name when the game shows none.
Descriptionstring?The game's description of the item. nil when it has none.
Weightnumber?What one of them weighs, in kilograms. nil for an item the game keeps no such facts about.
MaxStackinteger?How many fit in one stack. nil for an item the game keeps no such facts about.
MaxDurabilityinteger?Its durability when new. nil for an item the game gives no durability.
Iconstring?The path of its picture in the game's files. nil when it has none.

WaxShareStation

A station a pull or a stash can fill, as game.Items:Share reads it.

Used by game.Items:Share.

Open in the Explorer

FieldTypeDescription
stacksWaxItemStack[]What its input inventory holds, as List gives it.
sizeintegerHow many slots it has.
usedintegerHow many of them hold something.
accepts (optional)fun(item: string): booleanNil takes every item.

WaxContainerKind

Returned by game.Containers:Kinds.

Open in the Explorer

FieldTypeDescription
Rowstring
Namestring
Kind"storage" | "station" | "cargo"
CountintegerHow many of the kind are in range.

WaxNearbyOptions

Used by game.Containers:Nearby, game.Containers:Around, game.Containers:Kinds.

Open in the Explorer

OptionTypeDescription
kind"storage" | "station" | "cargo"Only structures of that kind.
holdingbooleanOnly structures with something in them.

WaxHeldOptions

Extends WaxNearbyOptions. Used by game.Containers:Held.

Open in the Explorer

OptionTypeDescription
around{ X: number, Y: number, Z: number }Measure from this place instead of the player.

On this page