mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2025-06-28 06:30:24 +02:00
Add u_i initialization and craft registration callbacks (#184)
Main purpose: custom recipe sorting provided by cuszom mods.
This commit is contained in:
@ -20,6 +20,64 @@ Grouped by use-case, afterwards sorted alphabetically.
|
||||
* Checks whether creative is enabled or the player has `creative`
|
||||
|
||||
|
||||
Callbacks
|
||||
---------
|
||||
|
||||
Register a callback that will be run whenever a craft is registered via unified_inventory.register_craft:
|
||||
|
||||
unified_inventory.register_on_craft_registered(
|
||||
function (item_name, options)
|
||||
-- item_name (string): name of the output item, equivalent to `ItemStack:get_name()`
|
||||
-- options (table): definition table of crafts registered by `unified_inventory.register_craft`
|
||||
end
|
||||
)
|
||||
|
||||
Register a callback that will be run after all mods have loaded and after the unified_inventory mod has initialised all its internal structures:
|
||||
|
||||
unified_inventory.register_on_initialized(callback)
|
||||
-- The callback is passed no arguments
|
||||
|
||||
|
||||
Accessing Data
|
||||
--------------
|
||||
|
||||
These methods should be used instead of accessing the unified_inventory data structures directly - this will ensure your code survives any potential restructuring of the mod.
|
||||
|
||||
Get a list of recipes for a particular output item:
|
||||
|
||||
unified_inventory.get_recipe_list(output_item)
|
||||
|
||||
Returns a list of tables, each holding a recipe definition, like:
|
||||
{
|
||||
{
|
||||
type = "normal",
|
||||
items = { "default:stick", "default:stick", "default:stick", "default:stick" },
|
||||
output = "default:wood",
|
||||
width = 2
|
||||
},
|
||||
{
|
||||
type = "shapeless",
|
||||
items = { "default:tree" },
|
||||
output = "default:wood 4",
|
||||
width = 0
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
Get a list of all the output items crafts have been registered for:
|
||||
|
||||
unified_inventory.get_registered_outputs()
|
||||
|
||||
Returns a list of item names, like:
|
||||
{
|
||||
"default:stone",
|
||||
"default:chest",
|
||||
"default:brick",
|
||||
"doors:door_wood",
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
Pages
|
||||
-----
|
||||
|
||||
|
Reference in New Issue
Block a user