Aktualizovat „mesecons/mesecons_mvps/init.lua“
This commit is contained in:
parent
7a5555a3e8
commit
29689c6335
1 changed files with 10 additions and 8 deletions
|
@ -135,29 +135,31 @@ function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky)
|
|||
return nodes
|
||||
end
|
||||
|
||||
function mesecon.mvps_push(pos, dir, maximum)
|
||||
return mesecon.mvps_push_or_pull(pos, dir, dir, maximum)
|
||||
function mesecon.mvps_push(pos, dir, maximum, owner)
|
||||
return mesecon.mvps_push_or_pull(pos, dir, dir, maximum, nil, owner)
|
||||
end
|
||||
|
||||
function mesecon.mvps_pull_all(pos, dir, maximum)
|
||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, true)
|
||||
function mesecon.mvps_pull_all(pos, dir, maximum, owner)
|
||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, true, owner)
|
||||
end
|
||||
|
||||
function mesecon.mvps_pull_single(pos, dir, maximum)
|
||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum)
|
||||
function mesecon.mvps_pull_single(pos, dir, maximum, owner)
|
||||
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, nil, owner)
|
||||
end
|
||||
|
||||
-- pos: pos of mvps; stackdir: direction of building the stack
|
||||
-- movedir: direction of actual movement
|
||||
-- maximum: maximum nodes to be pushed
|
||||
-- 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)
|
||||
|
||||
if not nodes then return end
|
||||
-- determine if one of the nodes blocks the push / pull
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue