mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 17:10:23 +02:00
Fix tab access on priv revoking
This commit is contained in:
11
src/api.lua
11
src/api.lua
@ -167,6 +167,13 @@ function i3.set_fs(player)
|
||||
sort_inventory(player, data)
|
||||
end
|
||||
|
||||
for i, tab in ipairs(i3.tabs) do
|
||||
if data.tab == i and tab.access and not tab.access(player, data) then
|
||||
data.tab = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local fs = make_fs(player, data)
|
||||
player:set_inventory_formspec(fs)
|
||||
end
|
||||
@ -221,8 +228,8 @@ function i3.set_tab(player, tabname)
|
||||
return
|
||||
end
|
||||
|
||||
for i, def in ipairs(i3.tabs) do
|
||||
if def.name == tabname then
|
||||
for i, tab in ipairs(i3.tabs) do
|
||||
if tab.name == tabname then
|
||||
data.tab = i
|
||||
return
|
||||
end
|
||||
|
11
src/gui.lua
11
src/gui.lua
@ -1516,6 +1516,7 @@ local function make_fs(player, data)
|
||||
fs("bg9", 0, 0, data.inv_width, full_height, PNG.bg_full, 10)
|
||||
|
||||
local tab = i3.tabs[data.tab]
|
||||
|
||||
if tab then
|
||||
tab.formspec(player, data, fs)
|
||||
end
|
||||
@ -1526,7 +1527,15 @@ local function make_fs(player, data)
|
||||
get_items_fs(fs, data, player, full_height)
|
||||
end
|
||||
|
||||
if #i3.tabs > 1 then
|
||||
local visible_tabs = 1
|
||||
|
||||
for _, def in ipairs(i3.tabs) do
|
||||
if visible_tabs < 2 and def.access and def.access(player, data) then
|
||||
visible_tabs++
|
||||
end
|
||||
end
|
||||
|
||||
if visible_tabs > 1 then
|
||||
get_tabs_fs(fs, player, data, full_height)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user