activate comparator when place opaque node

inactive comparator does not trigger mesecon.is_effector_off
This commit is contained in:
Henry Behrendt 2021-08-24 20:59:29 +02:00
parent 7f679e5808
commit d01a821325
1 changed files with 30 additions and 1 deletions

View File

@ -79,7 +79,7 @@ function mesecon.on_placenode(pos, node)
end
if minetest.get_item_group(node.name, "opaque") == 1 then
local is_powered, direct_source = mesecon.is_powered(pos)
local is_powered, direct_source, voltage = mesecon.is_powered(pos)
if is_powered and direct_source then
local neighbors = mesecon.mcl_get_neighbors(pos)
for n=1, #neighbors do
@ -92,6 +92,35 @@ function mesecon.on_placenode(pos, node)
elseif mesecon.is_effector_off(nnode.name) and minetest.get_item_group(nnode.name, "redstone_torch") == 0 then
mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
mesecon.activate(npos, nnode, neighbors[n].link, 1)
elseif mesecon.is_effector(nnode.name) and minetest.get_item_group(nnode.name, "redstone_torch") == 0 then
--eigen funktion für comparator schreiben
minetest.log("action", mesecon.postostring(pos) .. "--> on_placenode.is_effector: node.name->"..node.name.." f->".. mesecon.tabletostring(f))
if voltage<1 then
--ausschalten
--if mesecon.is_effector_on(node.name) then
minetest.log("action", mesecon.postostring(pos) .. "--> on_placenode.is_effector_on")
--mesecon.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
--mesecon.deactivate(f.pos, node, f.link, depth)
mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
mesecon.deactivate(npos, nnode, neighbors[n].link, 1)
--end
else
--einschalten
minetest.log("action", mesecon.postostring(pos) .. "--> on_placenode.is_effector_off")
mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
mesecon.activate(npos, nnode, neighbors[n].link, 1)
end
end
end
end