From 71f71798bf546859cf740cc0290f39e7b4ec19ce Mon Sep 17 00:00:00 2001 From: Henry Behrendt Date: Sun, 22 Aug 2021 19:18:30 +0200 Subject: [PATCH] some cleaning --- mesecons/internal.lua | 51 +++++++------------------------------------ mesecons/services.lua | 2 +- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 6ccde07..5552498 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -388,7 +388,7 @@ function mesecon.is_power_off(pos, rulename) return false end --- Turn off an equipotential section starting at `pos`, which outputs in the direction of `link`. +-- Turn on an equipotential section starting at `pos`, which outputs in the direction of `link`. -- Breadth-first search. Map is abstracted away in a voxelmanip. -- Follow all all conductor paths replacing conductors that were already -- looked at, activating / changing all effectors along the way. @@ -491,15 +491,7 @@ function mesecon.turnon(pos, link, voltage) --anschalten --mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link)) end - - - end - - --elseif node and mesecon.is_conductor_on(node, f.link) then - --spannung setzen, falls aktuelle spannung höher - -- local meta = minetest.get_meta(f.pos) - -- local v = math.max(f.voltage-1, meta:get_int("mesecon_voltage")) elseif mesecon.is_effector(node.name) then minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.is_effector: node.name->"..node.name.." f->".. mesecon.tabletostring(f)) @@ -512,29 +504,10 @@ function mesecon.turnon(pos, link, voltage) --end else --einschalten - -- eventuell immer ausführen, da sich spannung geändert haben könnte - --if mesecon.is_effector_off(node.name) then - minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.is_effector_off: f->".. mesecon.tabletostring(f)) - mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth) - --if mesecon.is_effector_off(node.name) then - mesecon.activate(f.pos, node, f.link, depth) - --end - --end + minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.is_effector_off: f->".. mesecon.tabletostring(f)) + mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth) + mesecon.activate(f.pos, node, f.link, depth) end - - - - - - - - - - - - - - end if node and f.link.spread and minetest.get_item_group(node.name, "opaque") == 1 then -- Call turnon on neighbors @@ -728,14 +701,6 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if sourcepos == nil then sourcepos = {} end - - - - - - - - local function power_walk(pos, home_pos, sourcepos, rulenames, rule, depth, voltage) local spread = false @@ -756,12 +721,12 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if depth == 0 or spread_tmp then local meta = minetest.get_meta(np) - minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage0=" .. voltage) + --minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage0=" .. voltage) voltage = math.max(voltage, meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15) - minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage1=" .. meta:get_string("mesecon_voltage")) - minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage2=" .. (meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15)) - minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage3=" .. voltage) + --minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage1=" .. meta:get_string("mesecon_voltage")) + --minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage2=" .. (meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15)) + --minetest.log("action", np.x .. "/" .. np.y .. "/" .. np.z .. "-->" .. "is_powered.voltage3=" .. voltage) insert(sourcepos, np) if spread_tmp then diff --git a/mesecons/services.lua b/mesecons/services.lua index 61da3ce..4d534cc 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -21,7 +21,7 @@ function mesecon.on_placenode(pos, node) -- Conductors: Send turnon signal when powered or replace by respective offstate conductor -- if placed conductor is an onstate one if mesecon.is_conductor(node.name) then - local sources, spread, voltage = mesecon.is_powered(pos) + local sources, _, voltage = mesecon.is_powered(pos) minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_placenode.voltage=" .. voltage) minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_placenode.sources=" .. mesecon.tabletostring(sources)) if sources and voltage>=1 then