mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-01-27 08:40:16 +01:00
MVPS: don't move non-physical objects
This commit is contained in:
parent
54de66b3e1
commit
212979932f
@ -274,27 +274,32 @@ function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
|||||||
dir = vector.multiply(dir, movefactor)
|
dir = vector.multiply(dir, movefactor)
|
||||||
for id, obj in pairs(minetest.get_objects_inside_radius(pos, #nodestack + 1)) do
|
for id, obj in pairs(minetest.get_objects_inside_radius(pos, #nodestack + 1)) do
|
||||||
local obj_pos = obj:get_pos()
|
local obj_pos = obj:get_pos()
|
||||||
local cbox = obj:get_properties().collisionbox
|
local props = obj:get_properties()
|
||||||
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 ok = true
|
local ok = true
|
||||||
for k, v in pairs(pos) do
|
if props.physical then
|
||||||
local edge1, edge2
|
local cbox = props.collisionbox
|
||||||
if k ~= dir_k then
|
local min_pos = vector.add(obj_pos, vector.new(cbox[1], cbox[2], cbox[3]))
|
||||||
edge1 = v - 0.51 -- More than 0.5 to move objects near to the stack.
|
local max_pos = vector.add(obj_pos, vector.new(cbox[4], cbox[5], cbox[6]))
|
||||||
edge2 = v + 0.51
|
for k, v in pairs(pos) do
|
||||||
else
|
local edge1, edge2
|
||||||
edge1 = v - 0.5 * dir_l
|
if k ~= dir_k then
|
||||||
edge2 = v + (#nodestack + 0.5 * movefactor) * dir_l
|
edge1 = v - 0.51 -- More than 0.5 to move objects near to the stack.
|
||||||
-- Make sure, edge1 is bigger than edge2:
|
edge2 = v + 0.51
|
||||||
if edge1 > edge2 then
|
else
|
||||||
edge1, edge2 = edge2, edge1
|
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
|
||||||
end
|
end
|
||||||
if min_pos[k] > edge2 or max_pos[k] < edge1 then
|
else
|
||||||
ok = false
|
ok = false -- not physical
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if ok then
|
if ok then
|
||||||
local ent = obj:get_luaentity()
|
local ent = obj:get_luaentity()
|
||||||
|
Loading…
Reference in New Issue
Block a user