Aktualizovat „mesecons/mesecons_mvps/init.lua“
This commit is contained in:
parent
7a5555a3e8
commit
29689c6335
|
@ -135,29 +135,31 @@ function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky)
|
||||||
return nodes
|
return nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.mvps_push(pos, dir, maximum)
|
function mesecon.mvps_push(pos, dir, maximum, owner)
|
||||||
return mesecon.mvps_push_or_pull(pos, dir, dir, maximum)
|
return mesecon.mvps_push_or_pull(pos, dir, dir, maximum, nil, owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.mvps_pull_all(pos, dir, maximum)
|
function mesecon.mvps_pull_all(pos, dir, maximum, owner)
|
||||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, true)
|
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, true, owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.mvps_pull_single(pos, dir, maximum)
|
function mesecon.mvps_pull_single(pos, dir, maximum, owner)
|
||||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum)
|
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, nil, owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pos: pos of mvps; stackdir: direction of building the stack
|
-- pos: pos of mvps; stackdir: direction of building the stack
|
||||||
-- movedir: direction of actual movement
|
-- movedir: direction of actual movement
|
||||||
-- maximum: maximum nodes to be pushed
|
-- maximum: maximum nodes to be pushed
|
||||||
-- all_pull_sticky: All nodes are sticky in the direction that they are pulled from
|
-- all_pull_sticky: All nodes are sticky in the direction that they are pulled from
|
||||||
function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sticky)
|
function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sticky, owner)
|
||||||
|
local owner = tostring(owner ~= "" and owner or "mvps")
|
||||||
local nodes = mesecon.mvps_get_stack(pos, movedir, maximum, all_pull_sticky)
|
local nodes = mesecon.mvps_get_stack(pos, movedir, maximum, all_pull_sticky)
|
||||||
|
|
||||||
if not nodes then return end
|
if not nodes then return end
|
||||||
-- determine if one of the nodes blocks the push / pull
|
-- determine if one of the nodes blocks the push / pull
|
||||||
for id, n in ipairs(nodes) do
|
for id, n in ipairs(nodes) do
|
||||||
if mesecon.is_mvps_stopper(n.node, movedir, nodes, id) or minetest.is_protected(n.pos, "mvps") then
|
if mesecon.is_mvps_stopper(n.node, movedir, nodes, id)
|
||||||
|
or minetest.is_protected(n.pos, owner) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue