From 212979932fd39ccdc73ddc30c37d442842ce0642 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:06:11 -0700 Subject: [PATCH] MVPS: don't move non-physical objects --- mesecons_mvps/init.lua | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index c047ed9..5098d5f 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -274,27 +274,32 @@ function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor) dir = vector.multiply(dir, movefactor) for id, obj in pairs(minetest.get_objects_inside_radius(pos, #nodestack + 1)) do local obj_pos = obj:get_pos() - local cbox = obj:get_properties().collisionbox - local min_pos = vector.add(obj_pos, vector.new(cbox[1], cbox[2], cbox[3])) - local max_pos = vector.add(obj_pos, vector.new(cbox[4], cbox[5], cbox[6])) + local props = obj:get_properties() local ok = true - for k, v in pairs(pos) do - local edge1, edge2 - if k ~= dir_k then - edge1 = v - 0.51 -- More than 0.5 to move objects near to the stack. - edge2 = v + 0.51 - else - edge1 = v - 0.5 * dir_l - edge2 = v + (#nodestack + 0.5 * movefactor) * dir_l - -- Make sure, edge1 is bigger than edge2: - if edge1 > edge2 then - edge1, edge2 = edge2, edge1 + if props.physical then + local cbox = props.collisionbox + local min_pos = vector.add(obj_pos, vector.new(cbox[1], cbox[2], cbox[3])) + local max_pos = vector.add(obj_pos, vector.new(cbox[4], cbox[5], cbox[6])) + for k, v in pairs(pos) do + local edge1, edge2 + if k ~= dir_k then + edge1 = v - 0.51 -- More than 0.5 to move objects near to the stack. + edge2 = v + 0.51 + else + edge1 = v - 0.5 * dir_l + edge2 = v + (#nodestack + 0.5 * movefactor) * dir_l + -- Make sure, edge1 is bigger than edge2: + if edge1 > edge2 then + edge1, edge2 = edge2, edge1 + end + end + if min_pos[k] > edge2 or max_pos[k] < edge1 then + ok = false + break end end - if min_pos[k] > edge2 or max_pos[k] < edge1 then - ok = false - break - end + else + ok = false -- not physical end if ok then local ent = obj:get_luaentity()