PlayerInventoryUI: fix updateNodeForm stuff
This commit is contained in:
@@ -265,7 +265,7 @@ function PlayerInventoryUI:addActiveNodeForm(nodePos, playerName)
|
||||
local stringPos = core.pos_to_string(nodePos)
|
||||
local playerNames = self.ActiveNodeForms[stringPos]
|
||||
if playerNames == nil then
|
||||
self.ActiveNodeForms[stringPos] = { playerNames }
|
||||
self.ActiveNodeForms[stringPos] = { playerName }
|
||||
else
|
||||
tableInsert(playerNames, playerName)
|
||||
end
|
||||
@@ -295,7 +295,7 @@ function PlayerInventoryUI:removeActiveNodeForm(nodePos, playerName)
|
||||
return
|
||||
end
|
||||
|
||||
tableRemoveValue(playerNames, playerName)
|
||||
self.ActiveNodeForms[stringPos] = tableRemoveValue(playerNames, playerName)
|
||||
end
|
||||
|
||||
-- We are overriding the `BaseUI.showForm` & `BaseUI.closeForm`.
|
||||
@@ -306,11 +306,6 @@ function PlayerInventoryUI:showForm(playerName)
|
||||
local player = core.get_player_by_name(playerName)
|
||||
assert(player ~= nil)
|
||||
|
||||
local nodePos = self:getContex(playerName, 'node_tab_pos')
|
||||
if nodePos ~= nil then
|
||||
self:addActiveNodeForm(nodePos, playerName)
|
||||
end
|
||||
|
||||
-- We overwrite the player's inventory definition so that the updated inventory
|
||||
-- is shown to the player when they press the "open inventory" key.
|
||||
player:set_inventory_formspec(PlayerInventoryUI:getFormSpecString(playerName))
|
||||
@@ -334,7 +329,7 @@ local function closeNodeTab(player)
|
||||
local playerName = player:get_player_name()
|
||||
local nodePos = PlayerInventoryUI:getContex(playerName, 'node_tab_pos')
|
||||
if nodePos ~= nil then
|
||||
PlayerInventoryUI:addActiveNodeForm(nodePos, playerName)
|
||||
PlayerInventoryUI:removeActiveNodeForm(nodePos, playerName)
|
||||
end
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, 'node_tab_pos', nil)
|
||||
|
||||
Reference in New Issue
Block a user