improvements on door controller and pusher

This commit is contained in:
Joachim Stolberg 2020-04-15 18:08:05 +02:00
parent 59a0a3248e
commit 61bbf5ea52
2 changed files with 18 additions and 11 deletions

View File

@ -101,6 +101,8 @@ local function pushing(pos, crd, meta, nvm)
nvm.item_count = nil
nvm.item_name = nil
crd.State:stop(pos, nvm)
local number = M(pos):get_string("node_number")
techage.send_single(number, nvm.rmt_num, "off")
else
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
@ -218,6 +220,7 @@ local tubing = {
local nvm = techage.get_nvm(pos)
CRD(pos).State:stop(pos, nvm)
nvm.item_count = math.min(config_item(pos, payload), 12)
nvm.rmt_num = src
CRD(pos).State:start(pos, nvm)
return true
elseif topic == "config" then

View File

@ -27,6 +27,7 @@ end
local function store_door_data(pos)
local nvm = techage.get_nvm(pos)
nvm.door_state = false
local numbers = M(pos):get_string("numbers")
nvm.door_blocks = {}
for _,num in ipairs(string.split(numbers, " ")) do
@ -40,19 +41,22 @@ end
local function swap_door_nodes(pos, open)
local nvm = techage.get_nvm(pos)
for _,item in ipairs(nvm.door_blocks or {}) do
if item.pos and item.name and item.param2 then
local node = techage.get_node_lvm(item.pos)
if open then
if node.name == item.name then
minetest.remove_node(item.pos)
if nvm.door_state ~= open then
nvm.door_state = open
for _,item in ipairs(nvm.door_blocks or {}) do
if item.pos and item.name and item.param2 then
local node = techage.get_node_lvm(item.pos)
if open then
if node.name == item.name then
minetest.remove_node(item.pos)
else
item.name = nil
end
elseif node.name == "air" then
minetest.add_node(item.pos, {name = item.name, param2 = item.param2})
else
item.name = nil
minetest.add_item(pos, item.pos, {name = item.name})
end
elseif node.name == "air" then
minetest.add_node(item.pos, {name = item.name, param2 = item.param2})
else
minetest.add_item(pos, item.pos, {name = item.name})
end
end
end