Loot.lua¶
Functions¶
loot.chestForItem¶
Get chest entity type for a given entity type.
Parameters:
| Name | Type | Description |
|---|---|---|
itemType |
string |
Item entity type. |
Returns: string
loot.createChestWithItem¶
loot.createChestWithItem(instance: LibLegelGen.Instance, itemType: string, hidden: boolean, entityType?: string, entityLevel?: number): LibLevelGen.Entity
Creates a chest containing a given item type.
Parameters:
| Name | Type | Description |
|---|---|---|
instance |
LibLegelGen.Instance |
The LibLevelGen instance of generated level. |
itemType |
string |
Item type to put inside of the chest. |
hidden |
boolean |
Whether the chest is only revealed when next to it. |
entityType? |
string |
Optional chest entity type (defaults to chest color based on the item) |
entityLevel? |
number |
Optional chest entity level |
Returns: LibLevelGen.Entity
loot.createChest¶
Creates a chest containing random item.
Parameters:
| Name | Type | Description |
|---|---|---|
instance |
LibLegelGen.Instance |
The LibLevelGen instance of the generated level. |
args? |
LibLevelGen.ChestChoiceArguments |
Extra parameters for the chest. |
loot.createGold¶
Create a gold entity.
Parameters:
| Name | Type | Description |
|---|---|---|
instance |
LibLegelGen.Instance |
The LibLevelGen instance of the generated level. |
amount |
number |
gold amount to create |
Returns: LibLevelGen.Entity
loot.createUrn¶
Create an urn entity.
Parameters:
| Name | Type | Description |
|---|---|---|
instance |
LibLegelGen.Instance |
The LibLevelGen instance of the generated level. |
Returns: LibLevelGen.Entity
loot.createCrate¶
loot.createCrate(instance: LibLegelGen.Instance, crateTypeOverride?: string, crateLevelOverride?: number): LibLevelGen.Entity
Create a create entity.
Parameters:
| Name | Type | Description |
|---|---|---|
instance |
LibLegelGen.Instance |
The LibLevelGen instance of the generated level. |
crateTypeOverride? |
string |
Force the crate to be a specific entity type. |
crateLevelOverride? |
number |
Force the crate to have a specific level. |
Returns: LibLevelGen.Entity
loot.placeChests¶
Place remaining chests.
Parameters:
| Name | Type | Description |
|---|---|---|
segment |
LibLevelGen.Segment |
Segment in which the remaining chests should be placed. |
loot.placeCrates¶
Place remaining crates.
Parameters:
| Name | Type | Description |
|---|---|---|
segment |
LibLevelGen.Segment |
Segment in which the remaining crates should be placed. |
Classes¶
LibLevelGen.ChestChoiceArguments extends ItemGeneration.ChoiceArguments¶
Interface for defining arguments of loot.createChest.
Properties:
| Name | Type | Description |
|---|---|---|
player? |
Entity |
Do not generate items that this player can’t pick up (defaults to a random initial player) |
banMask? |
ItemBan.Flag |
Ban flag to check on the player for item generation, defaults to GENERATE_ITEM_POOL |
slot? |
string |
If non-nil, only generate items matching that slot |
requiredComponents? |
string[] |
Only generate items that have all of those components |
excludedComponents? |
string[] |
Only generate items that have none of those components |
itemPool? |
string |
Component name used to determine item weights (the component needs a weights field) |
chanceType? |
string |
Compatibility alias for itemPool (only works for built-in item pools) |
levelBonus? |
integer |
Generate items from higher tiers |
chanceFunction? |
fun(Entity):integer |
Sets item weights (when set, chanceType and levelBonus are ignored) |
seenCounts? |
table<string,integer> |
Acts as a counter for tracking item generation to prevent duplicates, defaults to global counter |
depletionLimit? |
integer |
Items seen that many time will not be generated, defaults to 8 |
transmutedItem? |
Entity |
The item being transmuted, if any |
default? |
string |
If no items match the requirements, this is returned instead |
usePendingItems? |
boolean |
Prioritizes pending single-zone items |
ignoreProgression? |
boolean |
Allow generating locked items in single-zone |
result? |
string |
Resulting item type (used internally by event.itemGenerate) |
hidden? |
boolean |
Whether the chest starts visible or not |
chestType? |
string |
Chest entity type (defaults to chest color based on the item) |
chestLevel? |
number |
Chest entity type level |