Optionalrng: RngInterface | SeedProtectedconditionsGlobal conditions that can be used by loot table pools and entries.
The keys in the object are the function identifier used in the table entries/pools
Protected OptionaldefaultDefault RNG source when none is given
ProtectedfunctionsGlobal functions that can be used by loot table entries.
The keys in the object are the function identifier used in the table entries
Protected OptionalrngRNG source given by the end user
Protected OptionalrngRNG Constructor for making new RNGs
Whether to throw errors when conditions are missing, otherwise just does console.error
Whether to throw errors when functions are missing, otherwise just does console.error
StaticversionCreate an entry for a loot pool, either with object definition or from a loot table
Create a loot pool for use in a loot table
ProtectedfinishProtectedfinishProtectedgetAs we dont expose the class as default, in browser it would be nice if there was a way to create new instances. This can be done using this function.
Optionalrng: RngInterface | SeedProtectedisUsed for Typescript type guarding and parameter checking
ProtectedisUsed for Typescript type guarding and parameter checking
ProtectedisUsed for Typescript type guarding and parameter checking
Optionalrng: anyLoad a table from a file.
The file can be local or a url. If running in browser, it's always treated as a URL. When run in node, it will only treat it as a URL if it's prefixed with http.
This function expects a single table to be located in the file, as the base object.
Loads a table from a local file
Loads a table from a url
Load serialized tables from a file.
This is just a wrapper around unserializing json contents of a file.
Loads serialized tables from a local file
Load serialized tables from a url
Optionalrng: RngInterface | SeedProtectedpathTurns a JSON representation into a LootTable, and does the same for all nested tables inside pools recursively.
Serializes a LootTable ready for converting to text, e.g. JSON
Returns a key value object, where the keys are the loot table filenames/ids
Optionalhad?: Set<any>OptionalincludeOptionalkey?: string | numberconst result = await ultraloot.serialize(table);
result = {
kitchen_cupboard: {
fn: 'kitchen_cupboard',
pools: [
{
entries: [
{
type: 'table',
item: 'vegetables'
},
{
type: 'table',
item: 'fruit'
}
]
}
]
},
fruit_bowl: {
fn: 'fruit_bowl',
pools: [
{
entries: [
{
type: 'table',
item: 'fruit'
}
]
}
]
},
vegetables: {
fn: 'vegetables',
pools: [
{
entries: [
{
id: 'carrot'
},
{
id: 'cabbage'
},
]
}
]
},
fruit: {
fn: 'fruit',
pools: [
{
entries: [
{
id: 'apple'
},
{
id: 'pear'
},
]
}
]
}
}
Convert a LootTable to JSON
The table to serialize
Options
OptionalincludeWhether to include the RNG seed in the serialized tables
The resulting LootTable representation in a JSON string
ProtectedtransformProtectedtransformUnserializes tables serialized with the "serialize" function
Record of tables serialized using the "serialize" function
A key/value pairing of tables
Todo
detect recursively required tables
Example