Aktualizovat „mesecons/mesecons_movestones/init.lua“
This commit is contained in:
parent
9d33641453
commit
b7af07d508
1 changed files with 8 additions and 2 deletions
|
@ -40,12 +40,18 @@ end
|
||||||
|
|
||||||
-- registration functions:
|
-- registration functions:
|
||||||
function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
||||||
|
|
||||||
|
def.after_place_node = function(pos, placer)
|
||||||
|
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||||
|
end
|
||||||
|
|
||||||
local function movestone_move(pos, node, rulename)
|
local function movestone_move(pos, node, rulename)
|
||||||
local direction = get_movestone_direction(rulename, is_vertical)
|
local direction = get_movestone_direction(rulename, is_vertical)
|
||||||
local frontpos = vector.add(pos, direction)
|
local frontpos = vector.add(pos, direction)
|
||||||
|
|
||||||
-- ### Step 1: Push nodes in front ###
|
-- ### Step 1: Push nodes in front ###
|
||||||
local success, stack, oldstack = mesecon.mvps_push(frontpos, direction, max_push)
|
local owner = minetest.get_meta(pos):get_string("owner")
|
||||||
|
local success, stack, oldstack = mesecon.mvps_push(frontpos, direction, max_push, owner)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.get_node_timer(pos):start(timer_interval)
|
minetest.get_node_timer(pos):start(timer_interval)
|
||||||
return
|
return
|
||||||
|
@ -62,7 +68,7 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
||||||
-- ### Step 3: If sticky, pull stack behind ###
|
-- ### Step 3: If sticky, pull stack behind ###
|
||||||
if is_sticky then
|
if is_sticky then
|
||||||
local backpos = vector.subtract(pos, direction)
|
local backpos = vector.subtract(pos, direction)
|
||||||
success, stack, oldstack = mesecon.mvps_pull_all(backpos, direction, max_pull)
|
success, stack, oldstack = mesecon.mvps_pull_all(backpos, direction, max_pull, owner)
|
||||||
if success then
|
if success then
|
||||||
mesecon.mvps_move_objects(backpos, vector.multiply(direction, -1), oldstack, -1)
|
mesecon.mvps_move_objects(backpos, vector.multiply(direction, -1), oldstack, -1)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue