Code cleaning
This commit is contained in:
parent
3dc8e038f3
commit
88c20f8a3b
2
API.md
2
API.md
|
@ -25,7 +25,7 @@ i3.new_tab {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
fields = function(player, data, fields)
|
fields = function(player, data, fields)
|
||||||
i3.set_fs(player)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- Determine if the recipe panels must be hidden or not (must return a boolean)
|
-- Determine if the recipe panels must be hidden or not (must return a boolean)
|
||||||
|
|
13
init.lua
13
init.lua
|
@ -2023,7 +2023,7 @@ local function make_fs(player, data)
|
||||||
|
|
||||||
local tab = tabs[data.current_tab]
|
local tab = tabs[data.current_tab]
|
||||||
local hide_panels = tab and tab.hide_panels and tab.hide_panels(player, data)
|
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]",
|
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)
|
MIN_FORMSPEC_VERSION, data.xoffset + (show_panels and 8 or 0), full_height), styles)
|
||||||
|
@ -2843,7 +2843,10 @@ on_shutdown(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
on_receive_fields(function(player, formname, fields)
|
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 name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
@ -2858,7 +2861,11 @@ on_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
local tab = tabs[data.current_tab]
|
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)
|
end)
|
||||||
|
|
||||||
core.register_on_player_hpchange(function(player, hpchange)
|
core.register_on_player_hpchange(function(player, hpchange)
|
||||||
|
|
|
@ -6,10 +6,6 @@ i3.new_tab {
|
||||||
formspec = function(player, data, fs)
|
formspec = function(player, data, fs)
|
||||||
fs("label[3,1;Test 1]")
|
fs("label[3,1;Test 1]")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
fields = function(player, data, fields)
|
|
||||||
i3.set_fs(player)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.new_tab {
|
i3.new_tab {
|
||||||
|
@ -20,10 +16,6 @@ i3.new_tab {
|
||||||
formspec = function(player, data, fs)
|
formspec = function(player, data, fs)
|
||||||
fs("label[3,1;Test 2]")
|
fs("label[3,1;Test 2]")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
fields = function(player, data, fields)
|
|
||||||
i3.set_fs(player)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.new_tab {
|
i3.new_tab {
|
||||||
|
@ -54,8 +46,4 @@ i3.override_tab("test2", {
|
||||||
formspec = function(player, data, fs)
|
formspec = function(player, data, fs)
|
||||||
fs("label[3,1;Override!]")
|
fs("label[3,1;Override!]")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
fields = function(player, data, fields)
|
|
||||||
i3.set_fs(player)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
Ŝarĝante…
Reference in New Issue