summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-26 19:19:47 -0500
committercheapie <no-email-for-you@example.com>2024-04-26 19:19:47 -0500
commit97dfb694a2d40f38462dfd68ef2c9a7baa506f9a (patch)
treef45ec2b947843e7ad041c355fd95256f00fce566
parenta52c191b3f8f7de147846670a08ea21bd3c80fa0 (diff)
downloadcelevator-97dfb694a2d40f38462dfd68ef2c9a7baa506f9a.tar
celevator-97dfb694a2d40f38462dfd68ef2c9a7baa506f9a.tar.gz
celevator-97dfb694a2d40f38462dfd68ef2c9a7baa506f9a.tar.bz2
celevator-97dfb694a2d40f38462dfd68ef2c9a7baa506f9a.tar.xz
celevator-97dfb694a2d40f38462dfd68ef2c9a7baa506f9a.zip
Fix crash if someone tries connecting a PI/lantern to a dispatcher
-rw-r--r--pilantern.lua12
1 files changed, 6 insertions, 6 deletions
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)