summaryrefslogtreecommitdiff
path: root/pilantern.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-04 20:57:56 -0500
committercheapie <no-email-for-you@example.com>2024-04-04 20:57:56 -0500
commit12c3ce32dc9d6111b54a981cf39cb22f57c3800e (patch)
tree428312546d30fc52d08f2a01f5e49a1e3f19ff08 /pilantern.lua
parent0759be7c0a41170a92a99e53a5728efc5767bd5e (diff)
downloadcelevator-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 'pilantern.lua')
-rw-r--r--pilantern.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/pilantern.lua b/pilantern.lua
index 8986209..28ffd44 100644
--- a/pilantern.lua
+++ b/pilantern.lua
@@ -20,10 +20,26 @@ minetest.register_entity("celevator:incar_pi_entity",{
physical = false,
collisionbox = {0,0,0,0,0,0,},
textures = {"celevator_transparent.png",},
- _flashtimer = 0,
- _machinepos = "",
static_save = false,
},
+ on_step = function(self)
+ local pos = self.object:get_pos()
+ local props = self.object:get_properties()
+ if props.breath_max and props.breath_max ~= 0 then
+ local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",props.breath_max)))
+ if not carinfo then return end
+ local text = carinfo.pitext or "--"
+ if string.len(text) < 3 then text = string.rep(" ",3-string.len(text))..text end
+ text = string.sub(text,1,3)
+ local etex = celevator.pi.generatetexture(text,carinfo.piuparrow,carinfo.pidownarrow,false,true)
+ self.object:set_properties({textures = {etex}})
+ else
+ local carpos = vector.round(pos)
+ local carmeta = minetest.get_meta(carpos)
+ local carid = carmeta:get_int("carid")
+ if carid > 0 then self.object:set_properties({breath_max=carid}) end
+ end
+ end,
})
function celevator.pi.removeentity(pos)