summaryrefslogtreecommitdiff
path: root/pilantern.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2025-03-22 21:55:38 -0500
committercheapie <no-email-for-you@example.com>2025-03-22 21:55:38 -0500
commit2a2d7f18755845e2c68f872918261f4526d3cafb (patch)
tree2ef4b2497af351e2674b612e7c84e05fa8d78c95 /pilantern.lua
parent690374449d39aefe995c380b951aecdd18374ef3 (diff)
downloadcelevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar
celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.gz
celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.bz2
celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.xz
celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.zip
Improve robustness against players doing weird unsupported things
Diffstat (limited to 'pilantern.lua')
-rw-r--r--pilantern.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/pilantern.lua b/pilantern.lua
index 7dda0a5..29f3cf7 100644
--- a/pilantern.lua
+++ b/pilantern.lua
@@ -578,3 +578,30 @@ minetest.register_abm({
celevator.pi.updatedisplay(pos)
end,
})
+
+minetest.register_abm({
+ label = "Check PIs/lanterns for missing/replaced controllers",
+ nodenames = {"group:_celevator_pi","group:_celevator_lantern"},
+ interval = 15,
+ chance = 1,
+ action = function(pos)
+ local meta = minetest.get_meta(pos)
+ local carid = meta:get_int("carid")
+ if not (carid and carid > 0) then return end --Not set up yet
+ local carinfo = minetest.deserialize(celevator.storage:get_string("car"..carid))
+ if not carinfo then
+ celevator.pi.settext(pos," --")
+ meta:set_string("infotext","Error reading car information!\nPlease remove and replace this node.")
+ return
+ end
+ if not (carinfo.controllerpos and celevator.controller.iscontroller(carinfo.controllerpos)) then
+ celevator.pi.settext(pos," --")
+ meta:set_string("infotext","Controller is missing!\nPlease remove and replace this node.")
+ return
+ end
+ if celevator.get_meta(carinfo.controllerpos):get_int("carid") ~= carid then
+ celevator.pi.settext(pos," --")
+ meta:set_string("infotext","Controller found but with incorrect ID!\nPlease remove and replace this node.")
+ end
+ end,
+})