summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-20 13:22:16 -0500
committercheapie <no-email-for-you@example.com>2024-04-20 13:22:16 -0500
commit88a24a1fe8186fb81347ff2d61903ddfdb1752bc (patch)
tree20e55c604d53defb6e5db9c0b69bd53820924b5a
parented7e12a7bb03b2424a12d43857085cade10eae8b (diff)
downloadcelevator-88a24a1fe8186fb81347ff2d61903ddfdb1752bc.tar
celevator-88a24a1fe8186fb81347ff2d61903ddfdb1752bc.tar.gz
celevator-88a24a1fe8186fb81347ff2d61903ddfdb1752bc.tar.bz2
celevator-88a24a1fe8186fb81347ff2d61903ddfdb1752bc.tar.xz
celevator-88a24a1fe8186fb81347ff2d61903ddfdb1752bc.zip
Finish communication of other items with dispatcher
-rw-r--r--controllerfw.lua3
-rw-r--r--dispatcher.lua2
-rw-r--r--dispatcherfw.lua6
-rw-r--r--fs1switch.lua18
-rw-r--r--pilantern.lua12
5 files changed, 32 insertions, 9 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index c2a3449..bbe7278 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -615,6 +615,9 @@ elseif event.type == "dispatchermsg" then
elseif event.channel == "carcall" and mem.carstate == "normal" then
mem.carcalls[event.msg] = true
send(event.source,"status",mem)
+ elseif event.channel == "fs1switch" then
+ mem.fs1switch = event.msg
+ mem.fs1led = event.msg
end
end
diff --git a/dispatcher.lua b/dispatcher.lua
index af29a84..30e4ab5 100644
--- a/dispatcher.lua
+++ b/dispatcher.lua
@@ -396,7 +396,7 @@ function celevator.dispatcher.handlecallbutton(dispatcherpos,landing,dir)
celevator.dispatcher.run(dispatcherpos,event)
end
-function celevator.controller.handlefs1switch(dispatcherpos,on)
+function celevator.dispatcher.handlefs1switch(dispatcherpos,on)
local event = {
type = "fs1switch",
state = on,
diff --git a/dispatcherfw.lua b/dispatcherfw.lua
index 4e98d47..337c0b8 100644
--- a/dispatcherfw.lua
+++ b/dispatcherfw.lua
@@ -683,6 +683,12 @@ elseif event.type == "callbutton" then
elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then
mem.dncalls[event.landing] = true
end
+elseif event.type == "fs1switch" then
+ mem.fs1switch = event.state
+ mem.fs1led = event.state
+ for _,carid in ipairs(mem.params.carids) do
+ send(carid,"fs1switch",event.state)
+ end
end
fs("formspec_version[6]")
diff --git a/fs1switch.lua b/fs1switch.lua
index 8c426cc..d48ff8e 100644
--- a/fs1switch.lua
+++ b/fs1switch.lua
@@ -50,12 +50,26 @@ local function rightclick(pos,node,player)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
if not carinfo then return end
local controllerpos = carinfo.controllerpos
+ local dispatcher = false
+ if not controllerpos then
+ controllerpos = carinfo.dispatcherpos
+ dispatcher = true
+ end
+ if not controllerpos then return end
local controllermeta = minetest.get_meta(controllerpos)
if controllermeta:get_int("carid") ~= carid then return end
if node.name == "celevator:fs1switch_reset" or node.name == "celevator:fs1switch_reset_lit" then
- celevator.controller.handlefs1switch(controllerpos,false)
+ if dispatcher then
+ celevator.dispatcher.handlefs1switch(controllerpos,false)
+ else
+ celevator.controller.handlefs1switch(controllerpos,false)
+ end
elseif node.name == "celevator:fs1switch_on" or node.name == "celevator:fs1switch_on_lit" then
- celevator.controller.handlefs1switch(controllerpos,true)
+ if dispatcher then
+ celevator.dispatcher.handlefs1switch(controllerpos,true)
+ else
+ celevator.controller.handlefs1switch(controllerpos,true)
+ end
end
end
diff --git a/pilantern.lua b/pilantern.lua
index 71394e4..afb1b1e 100644
--- a/pilantern.lua
+++ b/pilantern.lua
@@ -166,7 +166,7 @@ minetest.register_node("celevator:pi",{
if tonumber(fields.carid) then
local carid = tonumber(fields.carid)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.pis then return end
table.insert(carinfo.pis,{pos=pos})
celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo))
local meta = minetest.get_meta(pos)
@@ -180,7 +180,7 @@ minetest.register_node("celevator:pi",{
local carid = meta:get_int("carid")
if carid == 0 then return end
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.pis then return end
for i,pi in pairs(carinfo.pis) do
if vector.equals(pos,pi.pos) then
table.remove(carinfo.pis,i)
@@ -347,7 +347,7 @@ for _,state in ipairs(validstates) do
local carid = tonumber(fields.carid)
local landing = tonumber(fields.landing)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.pis and carinfo.lanterns then return end
table.insert(carinfo.pis,{pos=pos})
table.insert(carinfo.lanterns,{pos=pos,landing=landing})
celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo))
@@ -362,7 +362,7 @@ for _,state in ipairs(validstates) do
local carid = meta:get_int("carid")
if carid == 0 then return end
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.pis and carinfo.lanterns then return end
for i,pi in pairs(carinfo.pis) do
if vector.equals(pos,pi.pos) then
table.remove(carinfo.pis,i)
@@ -418,7 +418,7 @@ for _,state in ipairs(validstates) do
local carid = tonumber(fields.carid)
local landing = tonumber(fields.landing)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.lanterns then return end
table.insert(carinfo.lanterns,{pos=pos,landing=landing})
celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo))
local meta = minetest.get_meta(pos)
@@ -431,7 +431,7 @@ for _,state in ipairs(validstates) do
local carid = meta:get_int("carid")
if carid == 0 then return end
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
- if not carinfo then return end
+ if not carinfo and carinfo.lanterns then return end
for i,lantern in pairs(carinfo.lanterns) do
if vector.equals(pos,lantern.pos) then
table.remove(carinfo.lanterns,i)