summaryrefslogtreecommitdiff
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
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
-rw-r--r--car.lua2
-rw-r--r--drive_entity.lua10
2 files changed, 6 insertions, 6 deletions
diff --git a/car.lua b/car.lua
index 2f7452c..13730e8 100644
--- a/car.lua
+++ b/car.lua
@@ -679,7 +679,7 @@ minetest.register_on_player_receive_fields(function(_,formname,fields)
local cartopboxpos = vector.add(rootpos,vector.rotate_around_axis(vector.new(0,3,1),vector.new(0,1,0),rootdir))
local erefs = minetest.get_objects_inside_radius(cartopboxpos,0.5)
for _,ref in pairs(erefs) do
- if toberemoved[ref:get_luaentity().name] then
+ if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then
ref:remove()
end
end
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