summaryrefslogtreecommitdiff
path: root/drive_entity.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-22 17:55:20 -0500
committercheapie <no-email-for-you@example.com>2024-04-22 17:55:20 -0500
commite29d179464abfda76d437b4dc03c57161dca40b0 (patch)
treec96c647abb583b4aecad9e97a6472d26b0d8211a /drive_entity.lua
parentfb49406dd5f3a49dcced3891164240a679948dcc (diff)
downloadcelevator-e29d179464abfda76d437b4dc03c57161dca40b0.tar
celevator-e29d179464abfda76d437b4dc03c57161dca40b0.tar.gz
celevator-e29d179464abfda76d437b4dc03c57161dca40b0.tar.bz2
celevator-e29d179464abfda76d437b4dc03c57161dca40b0.tar.xz
celevator-e29d179464abfda76d437b4dc03c57161dca40b0.zip
Prevent crashing when minetest.get_objects_inside_radius() returns garbage
Diffstat (limited to 'drive_entity.lua')
-rw-r--r--drive_entity.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/drive_entity.lua b/drive_entity.lua
index c1e4285..fb8521e 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -260,7 +260,7 @@ function celevator.drives.entity.entitiestonodes(refs,carid)
for _,eref in ipairs(refs) do
local pos = eref:get_pos()
local top = false
- if pos and (eref:get_luaentity().name == "celevator:car_moving" or eref:get_luaentity().name == "celevator:hwdoor_moving") then
+ if pos and eref:get_luaentity() and (eref:get_luaentity().name == "celevator:car_moving" or eref:get_luaentity().name == "celevator:hwdoor_moving") then
pos = vector.round(pos)
local node = {
name = eref:get_properties().wield_item,
@@ -270,7 +270,7 @@ function celevator.drives.entity.entitiestonodes(refs,carid)
minetest.set_node(pos,node)
eref:remove()
if carid then celevator.get_meta(pos):set_int("carid",carid) end
- elseif pos and eref:get_luaentity().name == "celevator:incar_pi_entity" then
+ elseif pos and eref:get_luaentity() and eref:get_luaentity().name == "celevator:incar_pi_entity" then
pos = vector.new(pos.x,math.floor(pos.y+0.5),pos.z)
eref:set_pos(pos)
elseif not ok then
@@ -287,10 +287,10 @@ function celevator.drives.entity.entitiestonodes(refs,carid)
if top then ppos.y = ppos.y+1.1 end
i:set_pos(ppos)
minetest.after(0.5,i.set_pos,i,ppos)
- elseif i:get_luaentity().name == "celevator:car_top_box" or i:get_luaentity().name == "celevator:car_door" then
+ elseif i:get_luaentity() and (i:get_luaentity().name == "celevator:car_top_box" or i:get_luaentity().name == "celevator:car_door") then
local epos = i:get_pos()
epos.y = math.floor(epos.y+0.5)
- if i:get_luaentity().name == "celevator:car_top_box" then
+ if i:get_luaentity() and i:get_luaentity().name == "celevator:car_top_box" then
epos.y = epos.y+0.1
end
i:set_pos(epos)
@@ -773,7 +773,7 @@ minetest.register_node("celevator:machine",{
end
local erefs = minetest.get_objects_inside_radius(sheavepos,0.5)
for _,ref in pairs(erefs) do
- if ref:get_luaentity().name == "celevator:sheave_moving" then
+ if ref:get_luaentity() and ref:get_luaentity().name == "celevator:sheave_moving" then
ref:remove()
end
end