Aktualizovat „mesecons/mesecons_pistons/init.lua“

This commit is contained in:
Milan2018 2020-09-10 19:08:36 +02:00
parent 29689c6335
commit 9d33641453

View file

@ -86,11 +86,12 @@ local piston_on = function(pos, node)
local pistonspec = get_pistonspec(node.name, "offname") local pistonspec = get_pistonspec(node.name, "offname")
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
local pusher_pos = vector.add(pos, dir) local pusher_pos = vector.add(pos, dir)
local success, stack, oldstack = mesecon.mvps_push(pusher_pos, dir, max_push) local owner = minetest.get_meta(pos):get_string("owner")
local success, stack, oldstack = mesecon.mvps_push(pusher_pos, dir, max_push, owner)
if not success then if not success then
return return
end end
minetest.set_node(pos, {param2 = node.param2, name = pistonspec.onname}) minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.onname})
minetest.set_node(pusher_pos, {param2 = node.param2, name = pistonspec.pusher}) minetest.set_node(pusher_pos, {param2 = node.param2, name = pistonspec.pusher})
minetest.sound_play("piston_extend", { minetest.sound_play("piston_extend", {
pos = pos, pos = pos,
@ -103,7 +104,7 @@ end
local function piston_off(pos, node) local function piston_off(pos, node)
local pistonspec = get_pistonspec(node.name, "onname") local pistonspec = get_pistonspec(node.name, "onname")
minetest.set_node(pos, {param2 = node.param2, name = pistonspec.offname}) minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.offname})
piston_remove_pusher(pos, node, not pistonspec.sticky) piston_remove_pusher(pos, node, not pistonspec.sticky)
if not pistonspec.sticky then if not pistonspec.sticky then
@ -111,7 +112,8 @@ local function piston_off(pos, node)
end end
local dir = minetest.facedir_to_dir(node.param2) local dir = minetest.facedir_to_dir(node.param2)
local pullpos = vector.add(pos, vector.multiply(dir, -2)) local pullpos = vector.add(pos, vector.multiply(dir, -2))
local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, dir, max_pull) local owner = minetest.get_meta(pos):get_string("owner")
local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, dir, max_pull, owner)
if success then if success then
mesecon.mvps_move_objects(pullpos, vector.multiply(dir, -1), oldstack, -1) mesecon.mvps_move_objects(pullpos, vector.multiply(dir, -1), oldstack, -1)
end end
@ -281,6 +283,9 @@ minetest.register_node("mesecons_pistons:piston_normal_off", {
}}, }},
on_rotate = piston_rotate, on_rotate = piston_rotate,
on_blast = mesecon.on_blastnode, on_blast = mesecon.on_blastnode,
after_place_node = function(pos, placer)
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
end,
}) })
-- onstate -- onstate
@ -359,6 +364,9 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", {
}}, }},
on_rotate = piston_rotate, on_rotate = piston_rotate,
on_blast = mesecon.on_blastnode, on_blast = mesecon.on_blastnode,
after_place_node = function(pos, placer)
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
end,
}) })
-- onstate -- onstate