Fix bug with reset button

This commit is contained in:
Joachim Stolberg 2023-03-28 18:34:54 +02:00
parent c3a492cb89
commit 1fcadc9ff7

View File

@ -67,6 +67,7 @@ local function get_new_nodename(item)
end end
local function get_node_name(nvm, slot) local function get_node_name(nvm, slot)
nvm.pos_list = nvm.pos_list or {}
local pos = nvm.pos_list[slot] local pos = nvm.pos_list[slot]
if pos then if pos then
return techage.get_node_lvm(pos).name return techage.get_node_lvm(pos).name
@ -228,6 +229,7 @@ end
-- Generate a table of currently available inventory and placed nodes -- Generate a table of currently available inventory and placed nodes
local function available_nodes(pos, nvm, item_list) local function available_nodes(pos, nvm, item_list)
local nodes = {} local nodes = {}
nvm.pos_list = nvm.pos_list or {}
for idx = 1, NUMSLOTS do for idx = 1, NUMSLOTS do
local item = item_list[idx] local item = item_list[idx]
@ -252,6 +254,7 @@ local function restore_config(pos, nvm)
local item_list = inv:get_list("main") local item_list = inv:get_list("main")
local stock = available_nodes(pos, nvm, item_list) local stock = available_nodes(pos, nvm, item_list)
local nodes = minetest.deserialize(meta:get_string("stored_config")) or {} local nodes = minetest.deserialize(meta:get_string("stored_config")) or {}
nvm.pos_list = nvm.pos_list or {}
inv:set_list("main", {}) inv:set_list("main", {})
item_list = inv:get_list("main") item_list = inv:get_list("main")
@ -421,7 +424,7 @@ minetest.register_node("techage:ta3_doorcontroller2", {
return return
elseif fields.record then elseif fields.record then
local inv = meta:get_inventory() local inv = meta:get_inventory()
nvm.pos_list = nil nvm.pos_list = {}
meta:set_string("status", S("Recording...")) meta:set_string("status", S("Recording..."))
local name = player:get_player_name() local name = player:get_player_name()
minetest.chat_send_player(name, S("Click on all the blocks that are part of the door/gate")) minetest.chat_send_player(name, S("Click on all the blocks that are part of the door/gate"))