diff --git a/API.md b/API.md index b98dcef..8a43e65 100644 --- a/API.md +++ b/API.md @@ -25,7 +25,7 @@ i3.new_tab { end, fields = function(player, data, fields) - i3.set_fs(player) + end, -- Determine if the recipe panels must be hidden or not (must return a boolean) diff --git a/init.lua b/init.lua index d0b7a9b..eabdf5f 100644 --- a/init.lua +++ b/init.lua @@ -2023,7 +2023,7 @@ local function make_fs(player, data) local tab = tabs[data.current_tab] local hide_panels = tab and tab.hide_panels and tab.hide_panels(player, data) - local show_panels = data.query_item and not hide_panels + local show_panels = data.query_item and tab and not hide_panels fs(fmt("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]", MIN_FORMSPEC_VERSION, data.xoffset + (show_panels and 8 or 0), full_height), styles) @@ -2843,7 +2843,10 @@ on_shutdown(function() end) on_receive_fields(function(player, formname, fields) - if formname ~= "" then return false end + if formname ~= "" then + return true + end + local name = player:get_player_name() local data = pdata[name] if not data then return end @@ -2858,7 +2861,11 @@ on_receive_fields(function(player, formname, fields) local tab = tabs[data.current_tab] - return true, tab and tab.fields and tab.fields(player, data, fields) + if tab and tab.fields then + return true, tab.fields(player, data, fields) + end + + return true, set_fs(player) end) core.register_on_player_hpchange(function(player, hpchange) diff --git a/test_tabs.lua b/test_tabs.lua index 2ad3e55..7d0b5ec 100644 --- a/test_tabs.lua +++ b/test_tabs.lua @@ -6,10 +6,6 @@ i3.new_tab { formspec = function(player, data, fs) fs("label[3,1;Test 1]") end, - - fields = function(player, data, fields) - i3.set_fs(player) - end, } i3.new_tab { @@ -20,10 +16,6 @@ i3.new_tab { formspec = function(player, data, fs) fs("label[3,1;Test 2]") end, - - fields = function(player, data, fields) - i3.set_fs(player) - end, } i3.new_tab { @@ -54,8 +46,4 @@ i3.override_tab("test2", { formspec = function(player, data, fs) fs("label[3,1;Override!]") end, - - fields = function(player, data, fields) - i3.set_fs(player) - end, })