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