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 /pilantern.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 'pilantern.lua')
-rw-r--r-- | pilantern.lua | 20 |
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) |