diff --git a/API.md b/API.md index 05e4789..909eaa9 100644 --- a/API.md +++ b/API.md @@ -2,6 +2,8 @@ ### Custom tabs +#### `i3.new_tab(def)` + Custom tabs can be added to the `i3` inventory as follow (example): ```Lua @@ -33,6 +35,16 @@ i3.new_tab { - `fs` is the formspec table which is callable with a metamethod. Each call adds a new entry. - `i3.set_fs(player)` must be called to update the formspec. +##### `i3.delete_tab(name)` + +Deletes a tab by name. + +##### `i3.get_tabs()` + +Returns the list of registered tabs. + +--- + ### Custom recipes Custom recipes are nonconventional crafts outside the main crafting grid. diff --git a/init.lua b/init.lua index 7d67b65..c32bb89 100644 --- a/init.lua +++ b/init.lua @@ -1987,6 +1987,22 @@ function i3.new_tab(def) tabs[#tabs + 1] = def end +function i3.get_tabs() + return tabs +end + +function i3.delete_tab(name) + if not true_str(name) then + return err "i3.delete_tab: name missing" + end + + for i, def in ipairs(tabs) do + if name == def.name then + remove(tabs, i) + end + end +end + local function init_data(player, name) local info = get_player_info(name)