Move obj_touching_plate_pos outside pp_on_timer

This commit is contained in:
MrRar
2023-04-23 17:01:48 -05:00
parent 15fa8765a5
commit 43e0639550

View File

@ -10,15 +10,7 @@ local pp_box_on = {
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
}
local function pp_on_timer(pos)
local node = minetest.get_node(pos)
local basename = minetest.registered_nodes[node.name].pressureplate_basename
-- This is a workaround for a strange bug that occurs when the server is started
-- For some reason the first time on_timer is called, the pos is wrong
if not basename then return end
local function obj_touching_plate_pos(obj_ref, plate_pos)
local function obj_touching_plate_pos(obj_ref, plate_pos)
local obj_pos = obj_ref:get_pos()
local props = obj_ref:get_properties()
if not (props and obj_pos and not obj_ref:get_attach()) then
@ -59,7 +51,15 @@ local function pp_on_timer(pos)
return true
end
return false
end
end
local function pp_on_timer(pos)
local node = minetest.get_node(pos)
local basename = minetest.registered_nodes[node.name].pressureplate_basename
-- This is a workaround for a strange bug that occurs when the server is started
-- For some reason the first time on_timer is called, the pos is wrong
if not basename then return end
local objs = minetest.get_objects_inside_radius(pos, 1)
local obj_touching = false