Skip to content

RollLoot

Rolls one of the game’s loot presets into a list of stacks.

The presets are the game’s own (inventory_defaultJunk_default, inventory_smallChest_rare, the shops’ …), read from your copy of the game by the tables export; the roll is the one a chest gets. Nothing for a preset the tables do not have (HasLootPreset). The list has the shape SetContainerItems takes and GivePlayerItem understands stack by stack.

RollLoot(preset)
Parameter Type
preset string the preset’s name

table - a list of {class=, amount=, health=}; {} for an unknown preset

-- a reward chest with a rich roll on top of its own contents
local items = GetContainerItems(REWARD) or {}
for _, stack in ipairs(RollLoot("inventory_smallChest_rare")) do items[#items + 1] = stack end
SetContainerItems(REWARD, items)

HasLootPreset · SetContainerPreset · SetContainerItems · the Doors and containers group of the index