From 97dfb694a2d40f38462dfd68ef2c9a7baa506f9a Mon Sep 17 00:00:00 2001 From: cheapie Date: Fri, 26 Apr 2024 19:19:47 -0500 Subject: Fix crash if someone tries connecting a PI/lantern to a dispatcher --- pilantern.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pilantern.lua') diff --git a/pilantern.lua b/pilantern.lua index 9293dd2..b79d872 100644 --- a/pilantern.lua +++ b/pilantern.lua @@ -169,7 +169,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 and carinfo.pis 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) @@ -183,7 +183,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 and carinfo.pis 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) @@ -358,7 +358,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 and carinfo.pis and carinfo.lanterns 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)) @@ -373,7 +373,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 and carinfo.pis and carinfo.lanterns 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) @@ -429,7 +429,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 and carinfo.lanterns 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) @@ -442,7 +442,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 and carinfo.lanterns 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) -- cgit v1.2.3