diff options
author | cheapie <no-email-for-you@example.com> | 2024-04-04 20:57:56 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-04-04 20:57:56 -0500 |
commit | 12c3ce32dc9d6111b54a981cf39cb22f57c3800e (patch) | |
tree | 428312546d30fc52d08f2a01f5e49a1e3f19ff08 /controller.lua | |
parent | 0759be7c0a41170a92a99e53a5728efc5767bd5e (diff) | |
download | celevator-12c3ce32dc9d6111b54a981cf39cb22f57c3800e.tar celevator-12c3ce32dc9d6111b54a981cf39cb22f57c3800e.tar.gz celevator-12c3ce32dc9d6111b54a981cf39cb22f57c3800e.tar.bz2 celevator-12c3ce32dc9d6111b54a981cf39cb22f57c3800e.tar.xz celevator-12c3ce32dc9d6111b54a981cf39cb22f57c3800e.zip |
Make in-car PI work
Diffstat (limited to 'controller.lua')
-rw-r--r-- | controller.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/controller.lua b/controller.lua index cc4f68d..a36dee1 100644 --- a/controller.lua +++ b/controller.lua @@ -411,6 +411,7 @@ function celevator.controller.finish(pos,mem,changedinterrupts) local meta = minetest.get_meta(pos) local carid = meta:get_int("carid") local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + local carinfodirty = false if not carinfo then minetest.log("error","[celevator] [controller] Bad car info for controller at "..minetest.pos_to_string(pos)) return @@ -453,6 +454,8 @@ function celevator.controller.finish(pos,mem,changedinterrupts) local oldpitext = oldmem.pifloor or "--" local newpitext = mem.pifloor or "--" if oldpitext ~= newpitext then + carinfodirty = true + carinfo.pitext = newpitext local pis = carinfo.pis for _,pi in pairs(pis) do celevator.pi.settext(pi.pos,newpitext) @@ -463,12 +466,16 @@ function celevator.controller.finish(pos,mem,changedinterrupts) local oldpidownarrow = oldmem.pidownarrow local newpidownarrow = mem.pidownarrow if oldpiuparrow ~= newpiuparrow then + carinfodirty = true + carinfo.piuparrow = newpiuparrow local pis = carinfo.pis for _,pi in pairs(pis) do celevator.pi.setarrow(pi.pos,"up",newpiuparrow) end end if oldpidownarrow ~= newpidownarrow then + carinfodirty = true + carinfo.pidownarrow = newpidownarrow local pis = carinfo.pis for _,pi in pairs(pis) do celevator.pi.setarrow(pi.pos,"down",newpidownarrow) @@ -501,6 +508,9 @@ function celevator.controller.finish(pos,mem,changedinterrupts) celevator.storage:set_string("controller_equeue",minetest.serialize(celevator.controller.equeue)) celevator.controller.run(pos,event) end + if carinfodirty then + celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo)) + end end end |