Implement invtab ordering
This commit is contained in:
parent
4f9725fe46
commit
db8db66c20
@ -140,6 +140,24 @@ In that case, it can only be reached by a function call.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### `rp_formspec.set_invtab_order(order)`
|
||||||
|
|
||||||
|
Overrides the order in which the invtabs are shown, starting
|
||||||
|
with the top tab.
|
||||||
|
|
||||||
|
* `order`: List of invtab IDs to order.
|
||||||
|
|
||||||
|
`order` can contain unknown invtab IDs, they will be ignored.
|
||||||
|
Any invtab not listed in `order` will be added at the end
|
||||||
|
in a non-predictable order.
|
||||||
|
|
||||||
|
If this function is called multiple times, the last
|
||||||
|
time this function is called is the one that actually
|
||||||
|
takes effect. If you want to override the order set
|
||||||
|
by another mod, depend on this mod first.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `rp_formspec.registered_invpages`
|
### `rp_formspec.registered_invpages`
|
||||||
|
|
||||||
Table which lists all registered invpages.
|
Table which lists all registered invpages.
|
||||||
|
@ -291,13 +291,27 @@ local function get_invtabs()
|
|||||||
for o=1, #registered_invtabs_order do
|
for o=1, #registered_invtabs_order do
|
||||||
local tabname = registered_invtabs_order[o]
|
local tabname = registered_invtabs_order[o]
|
||||||
local def = rp_formspec.registered_invtabs[tabname]
|
local def = rp_formspec.registered_invtabs[tabname]
|
||||||
form = form .. rp_formspec.tab(tabx, taby, "_rp_formspec_tab_"..tabname, def.icon, def.tooltip)
|
if def then
|
||||||
taby = taby + tabplus
|
form = form .. rp_formspec.tab(tabx, taby, "_rp_formspec_tab_"..tabname, def.icon, def.tooltip)
|
||||||
|
taby = taby + tabplus
|
||||||
|
end
|
||||||
end
|
end
|
||||||
invtabs_cached = form
|
invtabs_cached = form
|
||||||
return form
|
return form
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function rp_formspec.set_invtab_order(order)
|
||||||
|
registered_invtabs_order = table.copy(order)
|
||||||
|
local already_ordered = {}
|
||||||
|
for o=1, #order do
|
||||||
|
already_ordered[order[o]] = true
|
||||||
|
end
|
||||||
|
for k,v in pairs(rp_formspec.registered_invtabs) do
|
||||||
|
if not already_ordered[k] then
|
||||||
|
table.insert(registered_invtabs_order, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Pages
|
-- Pages
|
||||||
|
|
||||||
|
11
mods/rp_formspec_config/init.lua
Normal file
11
mods/rp_formspec_config/init.lua
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
-- Set the order of inventory menu tabs
|
||||||
|
rp_formspec.set_invtab_order({
|
||||||
|
"rp_crafting:crafting",
|
||||||
|
"rp_armor:armor",
|
||||||
|
"rp_achievements:achievements",
|
||||||
|
"rp_player_skins:player_skins",
|
||||||
|
"rp_creative:creative",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Note: If you want to override this order, depend
|
||||||
|
-- on this mod and call this function again.
|
3
mods/rp_formspec_config/mod.conf
Normal file
3
mods/rp_formspec_config/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = rp_formspec_config
|
||||||
|
description = Some configuration tweaks for rp_formspec
|
||||||
|
depends = rp_formspec, rp_crafting, rp_creative, rp_player_skins, rp_armor, rp_achievements
|
Loading…
x
Reference in New Issue
Block a user