diff --git a/mcl_comparators/init.lua b/mcl_comparators/init.lua index 917e497..7c472e9 100644 --- a/mcl_comparators/init.lua +++ b/mcl_comparators/init.lua @@ -46,13 +46,14 @@ local function comparator_turnon(params) end function comparator_removevoltage(pos, link, voltage) - local frontiers = {{pos = pos, link = link}} - local signals = {} - local rec_on = {} + local cur_vol = voltage+1 minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_removevoltage" .. " v="..cur_vol) + local frontiers = {{pos = pos, link = link, voltage=cur_vol}} + + local depth = 1 while frontiers[1] do local f = table.remove(frontiers, 1) @@ -63,7 +64,7 @@ function comparator_removevoltage(pos, link, voltage) local tmp_vol = (meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15) - if tmp_vol=1 then + if tmp_vol=1 then --solange spannung niedriger wird cur_vol = tmp_vol meta:set_int("mesecon_voltage", 0) @@ -72,7 +73,7 @@ function comparator_removevoltage(pos, link, voltage) local np = vector.add(f.pos, r) -- check neighbors for _, l in pairs(mesecon.rules_link_rule_all(f.pos, r)) do - table.insert(frontiers, {pos = np, link = l}) + table.insert(frontiers, {pos = np, link = l, voltage=cur_vol}) end end end