forked from minetest-mods/mesecons
MVPS: pull objects (#374)
This commit is contained in:
parent
1b10610f92
commit
748446b3cc
@ -50,7 +50,6 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
||||
minetest.get_node_timer(pos):start(timer_interval)
|
||||
return
|
||||
end
|
||||
mesecon.mvps_process_stack(stack)
|
||||
mesecon.mvps_move_objects(frontpos, direction, oldstack)
|
||||
|
||||
-- ### Step 2: Move the movestone ###
|
||||
@ -61,9 +60,13 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
||||
minetest.get_node_timer(frontpos):start(timer_interval)
|
||||
|
||||
-- ### Step 3: If sticky, pull stack behind ###
|
||||
if is_sticky then
|
||||
local backpos = vector.subtract(pos, direction)
|
||||
mesecon.mvps_pull_all(backpos, direction, max_pull)
|
||||
if not is_sticky then
|
||||
return
|
||||
end
|
||||
local backpos = vector.subtract(pos, direction)
|
||||
success, stack, oldstack = mesecon.mvps_pull_all(backpos, direction, max_pull)
|
||||
if success then
|
||||
mesecon.mvps_move_objects(backpos, vector.multiply(direction, -1), oldstack, -1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -205,7 +205,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||
return true, nodes, oldstack
|
||||
end
|
||||
|
||||
function mesecon.mvps_move_objects(pos, dir, nodestack)
|
||||
function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
||||
local objects_to_move = {}
|
||||
local dir_k
|
||||
local dir_l
|
||||
@ -216,6 +216,8 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
|
||||
break
|
||||
end
|
||||
end
|
||||
movefactor = movefactor or 1
|
||||
dir = vector.multiply(dir, movefactor)
|
||||
for id, obj in pairs(minetest.object_refs) do
|
||||
local obj_pos = obj:get_pos()
|
||||
local cbox = obj:get_properties().collisionbox
|
||||
@ -229,7 +231,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
|
||||
edge2 = v + 0.51
|
||||
else
|
||||
edge1 = v - 0.5 * dir_l
|
||||
edge2 = v + (#nodestack + 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
|
||||
|
@ -101,10 +101,12 @@ local function piston_off(pos, node)
|
||||
if not pistonspec.sticky then
|
||||
return
|
||||
end
|
||||
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||
local pullpos = vector.add(pos, vector.multiply(dir, 2))
|
||||
local stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), max_pull)
|
||||
mesecon.mvps_process_stack(pos, dir, stack)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local pullpos = vector.add(pos, vector.multiply(dir, -2))
|
||||
local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, dir, max_pull)
|
||||
if success then
|
||||
mesecon.mvps_move_objects(pullpos, vector.multiply(dir, -1), oldstack, -1)
|
||||
end
|
||||
end
|
||||
|
||||
local orientations = {
|
||||
|
Loading…
Reference in New Issue
Block a user