Fix bollard behavior
The bollards were previously changing state every time they got a mesecons signal, which broke things when 2+ mesecons were connected, and generally resulted in strange behavior otherwise.
This commit is contained in:
parent
132844bd81
commit
5a0ff5e589
@ -4,7 +4,7 @@
|
||||
Optional: true
|
||||
]]
|
||||
|
||||
local function toggle_bollard(pos, node, clicker, itemstack, pointed_thing)
|
||||
local function toggle_bollard(pos, node, clicker, itemstack, pointed_thing, to_role)
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name].bollard then
|
||||
local n = minetest.get_node(pos)
|
||||
local ndef = minetest.registered_nodes[n.name]
|
||||
@ -14,6 +14,12 @@ local function toggle_bollard(pos, node, clicker, itemstack, pointed_thing)
|
||||
return
|
||||
end
|
||||
end
|
||||
if to_role then
|
||||
local to = minetest.registered_nodes[ndef.bollard.counterpart]
|
||||
if to.bollard.role ~= to_role then
|
||||
return
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name = ndef.bollard.counterpart, param2 = n.param2})
|
||||
end
|
||||
end
|
||||
@ -26,8 +32,11 @@ minetest.register_node("streets:bollard_driver", {
|
||||
mesecons = {
|
||||
effector = {
|
||||
rules = mesecon.rules.default,
|
||||
action_change = function (pos, node)
|
||||
toggle_bollard(vector.add(pos, vector.new(0, 1, 0)), node, nil, nil, {type = "node", under = vector.add(pos, vector.new(0, -1, 0)), above = vector.add(pos, vector.new(0, 1, 0))})
|
||||
action_on = function (pos, node)
|
||||
toggle_bollard(vector.add(pos, vector.new(0, 1, 0)), node, nil, nil, {type = "node", under = vector.add(pos, vector.new(0, -1, 0)), above = vector.add(pos, vector.new(0, 1, 0))},"up")
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
toggle_bollard(vector.add(pos, vector.new(0, 1, 0)), node, nil, nil, {type = "node", under = vector.add(pos, vector.new(0, -1, 0)), above = vector.add(pos, vector.new(0, 1, 0))},"down")
|
||||
end
|
||||
}}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user