Bugfix: calling :remove() deleted all the panels assigned to a player

master
Zughy 2020-08-03 01:09:18 +02:00
parent a567db7f2e
commit 17a810ed79
1 changed files with 9 additions and 1 deletions

10
api.lua
View File

@ -3,6 +3,7 @@ panel_lib.panels = {} -- KEY: p_name; VALUE: {{"panel name" = panel}, {"pa
local function clone_table() end
Panel = {
name = "",
-- player to show the panel to
player_name = "",
-- ids of the hud of the player
@ -42,6 +43,13 @@ function Panel:new(def)
setmetatable(panel, metapanel)
metapanel.__index = metapanel
if not def.name or type(def.name) ~= "string" then
minetest.log("warning", "[PANEL_LIB] Can't create a panel without a proper name, aborting")
return
else
panel.name = def.name
end
if def.position then
panel.background_def.position = def.position
panel.title_def.position = def.position
@ -202,7 +210,7 @@ end
function Panel:remove()
panel_lib.panels[self.player_name] = nil
panel_lib.panels[self.player_name][self.name] = nil
self:hide()
self = nil
end