custom_creative_tabs 🔗
Custom creative-inventory tabs for MCL-based games (MineClone2, Mineclonia, VoxeLibre) on Luanti / Minetest.
The mod adds a paginated row of extra tabs to the creative inventory. Tabs are registered from other mods and can be filled either explicitly, or automatically by item prefix, group, or owning mod.
On its own this mod does nothing visible 🔗
It only adds an API. The creative inventory will look exactly like vanilla MCL until another mod registers a tab. If you are a player, you most likely want to install it as a dependency of a mod that uses it.
Usage 🔗
Page 0 of the navigation row shows only a ► button so vanilla tabs stay visible. Pressing ► reveals up to 12 custom tabs per page (5 on the top row, 7 on the bottom row), with ◄ / ► arrows between pages. Selecting a custom tab hides the vanilla tabs and lists the tab's items in the creative grid.
API 🔗
The mod exposes a single global table: custom_creative.
custom_creative.register_tab(def) 🔗
Registers a new tab. def:
id(string, required): unique identifier, snake_case (preferrably).label(string, required): tab tooltip and inventory caption.icon(string, required): item name used as the button icon.items(selector, optional): how to populate the tab. If omitted, the tab is filled manually viaadd_item/add_items.
Selectors 🔗
items = {"mymod:a", "mymod:b"} -- explicit list
items = {prefix = "mymod:"} -- everything in a namespace
items = {group = "wool"} -- everything in a group
items = {mod = "mymod"} -- everything from a mod
items = function() return {...} end -- computed at mods_loaded
prefix, group, mod can be combined (logical AND). Automatic selectors skip items with not_in_creative_inventory > 0.
custom_creative.add_item(tab_id, item_name) / add_items(tab_id, list) 🔗
Append items to an existing tab. Useful when another mod wants to contribute to a tab it does not own.
Example 🔗
custom_creative.register_tab({
id = "mymod",
label = "My Mod",
icon = "mymod:logo",
items = {mod = "mymod"},
})
A complete worked example covering every selector type lives in example_mod/ in the source repository.
A fair warning 🔗
The implementation is probably very hacky. There is no proper API to extend the MCL creative inventory, so the mod patches the formspec string after mcl_inventory has produced it, by gsub-ing tokens it knows by heart. It works, and I find it useful day-to-day, but I am under no illusion that this is the right way to do things. If MCL ever exposes a real registration API, throw this mod away and use that.
Bug reports 🔗
This is my first public mod. I write very little Lua, so the code is almost certainly buggy, in places more convoluted than it has to be, and probably outright redundant in others. Please open an issue if you spot anything off. I would rather hear about a hundred small things than have them sit unnoticed.
Limitations 🔗
- Selectors are resolved once at
mods_loaded. Items registered later need to come throughadd_item/add_items. - A maximum of 12 custom tabs per page; additional tabs spill onto further pages.
- The icon item must exist at
mods_loaded, otherwise a warning is logged and the button shows a blank slot.
Full documentation, design notes, and the story of the dead-ends I walked into are in the README on the source repository.