remove debug-lines
This commit is contained in:
parent
3f3e7cc995
commit
150125c218
|
@ -49,7 +49,6 @@ function comparator_removevoltage(pos, link, voltage)
|
||||||
|
|
||||||
|
|
||||||
local cur_vol = voltage+1
|
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 frontiers = {{pos = pos, link = link, voltage=cur_vol}}
|
||||||
|
|
||||||
|
@ -91,7 +90,6 @@ end
|
||||||
-- Functions that set the correct node type an schedule a turnon/off
|
-- Functions that set the correct node type an schedule a turnon/off
|
||||||
|
|
||||||
local function comparator_activate(pos, node, voltage, lower_voltage, old_voltage)
|
local function comparator_activate(pos, node, voltage, lower_voltage, old_voltage)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_activate" .. " v="..voltage .. " lv=" .. tostring(lower_voltage))
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 })
|
minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 })
|
||||||
minetest.after(0.1, comparator_turnon , {pos = pos, node = node, voltage = voltage, lower_voltage=lower_voltage, old_voltage=old_voltage})
|
minetest.after(0.1, comparator_turnon , {pos = pos, node = node, voltage = voltage, lower_voltage=lower_voltage, old_voltage=old_voltage})
|
||||||
|
@ -99,7 +97,6 @@ end
|
||||||
|
|
||||||
|
|
||||||
local function comparator_deactivate(pos, node)
|
local function comparator_deactivate(pos, node)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_deactivate " .. mesecon.postostring(pos))
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 })
|
minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 })
|
||||||
minetest.after(0.1, comparator_turnoff, {pos = pos, node = node})
|
minetest.after(0.1, comparator_turnoff, {pos = pos, node = node})
|
||||||
|
@ -118,14 +115,11 @@ local function container_inventory_nonempty(pos, rule)
|
||||||
-- Ignore stale nodes
|
-- Ignore stale nodes
|
||||||
if not invnodedef then return 0, false end
|
if not invnodedef then return 0, false end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.1")
|
|
||||||
|
|
||||||
-- Only accept containers. When a container is dug, it's inventory
|
-- Only accept containers. When a container is dug, it's inventory
|
||||||
-- seems to stay. and we don't want to accept the inventory of an air
|
-- seems to stay. and we don't want to accept the inventory of an air
|
||||||
-- block
|
-- block
|
||||||
if not invnodedef.groups.container then
|
if not invnodedef.groups.container then
|
||||||
if minetest.get_item_group(invnode.name, "opaque") == 1 and rule then
|
if minetest.get_item_group(invnode.name, "opaque") == 1 and rule then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.2")
|
|
||||||
--found opaque block -> check next block
|
--found opaque block -> check next block
|
||||||
local backback_pos = vector.add(pos, rule)
|
local backback_pos = vector.add(pos, rule)
|
||||||
local bb_voltage, _ = container_inventory_nonempty(backback_pos, nil)
|
local bb_voltage, _ = container_inventory_nonempty(backback_pos, nil)
|
||||||
|
@ -135,21 +129,14 @@ local function container_inventory_nonempty(pos, rule)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.3")
|
|
||||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||||
if not inv then return 0, false end
|
if not inv then return 0, false end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.4")
|
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv= " .. mesecon.tabletostring(inv:get_lists()))
|
|
||||||
|
|
||||||
|
|
||||||
if invnode.name=="mcl_jukebox:jukebox" then
|
if invnode.name=="mcl_jukebox:jukebox" then
|
||||||
if not inv:is_empty("main") then
|
if not inv:is_empty("main") then
|
||||||
-- Jukebox contains a disc: Stop music and remove disc
|
-- Jukebox contains a disc: Stop music and remove disc
|
||||||
local record = inv:get_stack("main", 1)
|
local record = inv:get_stack("main", 1)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.juke="..mesecon.tabletostring(record:get_name()))
|
|
||||||
if mcl_jukebox.registered_records[record:get_name()] then
|
if mcl_jukebox.registered_records[record:get_name()] then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.juke="..mesecon.tabletostring(mcl_jukebox.registered_records[record:get_name()]))
|
|
||||||
local ident = mcl_jukebox.registered_records[record:get_name()][3]
|
local ident = mcl_jukebox.registered_records[record:get_name()][3]
|
||||||
local t = {
|
local t = {
|
||||||
id_13 = 1,
|
id_13 = 1,
|
||||||
|
@ -167,7 +154,6 @@ local function container_inventory_nonempty(pos, rule)
|
||||||
id_Pigstep = 13,
|
id_Pigstep = 13,
|
||||||
}
|
}
|
||||||
local vol = t["id_"..ident]
|
local vol = t["id_"..ident]
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.juke "..ident.."="..vol)
|
|
||||||
if vol then return vol, false end
|
if vol then return vol, false end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -178,14 +164,9 @@ local function container_inventory_nonempty(pos, rule)
|
||||||
|
|
||||||
for listname, _ in pairs(inv:get_lists()) do
|
for listname, _ in pairs(inv:get_lists()) do
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv.size= " .. inv:get_size(listname))
|
|
||||||
|
|
||||||
local stack = inv:get_stack(listname, 1)
|
local stack = inv:get_stack(listname, 1)
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv.stack1= " .. mesecon.tabletostring(stack))
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv.stack1.max= " .. stack:get_stack_max())
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv.stack1.count= " .. stack:get_count())
|
|
||||||
|
|
||||||
local st_size = inv:get_size(listname)
|
local st_size = inv:get_size(listname)
|
||||||
inv_space = inv_space + (64 * st_size)
|
inv_space = inv_space + (64 * st_size)
|
||||||
for i = 1,st_size do
|
for i = 1,st_size do
|
||||||
|
@ -195,12 +176,8 @@ local function container_inventory_nonempty(pos, rule)
|
||||||
--if not inv:is_empty(listname) then return true, 15 end
|
--if not inv:is_empty(listname) then return true, 15 end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.inv_space= " .. inv_space)
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.item_count= " .. item_count)
|
|
||||||
|
|
||||||
if item_count>0 then
|
if item_count>0 then
|
||||||
local voltage = math.floor(1 + (item_count/inv_space*14))
|
local voltage = math.floor(1 + (item_count/inv_space*14))
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "container_inventory_nonempty.voltage= " .. voltage)
|
|
||||||
return voltage, false
|
return voltage, false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -233,7 +210,6 @@ local function comparator_desired_on(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
voltage = math.max(vo_back, vo_coin, vo_sso)
|
voltage = math.max(vo_back, vo_coin, vo_sso)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_desired_on1.voltage= " .. voltage .. " vb="..vo_back.." vc="..vo_coin.." vs="..vo_sso)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,16 +225,11 @@ local function comparator_desired_on(pos, node)
|
||||||
side_voltage = math.max(side_voltage, s_voltage)
|
side_voltage = math.max(side_voltage, s_voltage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_desired_on2.voltage= " .. voltage)
|
|
||||||
|
|
||||||
if mode == "comp" then
|
if mode == "comp" then
|
||||||
-- Comparators in comparison mode
|
-- Comparators in comparison mode
|
||||||
if side_voltage > voltage then
|
if side_voltage > voltage then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_desired_on3.voltage= " .. voltage)
|
|
||||||
return false, 0
|
return false, 0
|
||||||
else
|
else
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "comparator_desired_on4.voltage= " .. voltage)
|
|
||||||
return true, voltage
|
return true, voltage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -310,8 +281,6 @@ local function update_self(pos, node)
|
||||||
local new_state, new_voltage = comparator_desired_on(pos, node)
|
local new_state, new_voltage = comparator_desired_on(pos, node)
|
||||||
|
|
||||||
if (new_state ~= old_state) or (old_voltage~=new_voltage) then
|
if (new_state ~= old_state) or (old_voltage~=new_voltage) then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "update_self.ov=" .. old_voltage .. " nv="..new_voltage.." os="..tostring(old_state).." ns="..tostring(new_state))
|
|
||||||
|
|
||||||
if old_voltage~=new_voltage then meta:set_int("mesecon_voltage", new_voltage) end
|
if old_voltage~=new_voltage then meta:set_int("mesecon_voltage", new_voltage) end
|
||||||
if new_state then
|
if new_state then
|
||||||
comparator_activate(pos, node, new_voltage, (new_voltage<old_voltage), old_voltage)
|
comparator_activate(pos, node, new_voltage, (new_voltage<old_voltage), old_voltage)
|
||||||
|
|
|
@ -83,7 +83,6 @@ mesecon.queue:add_function("receptor_on", function (pos, rules, voltage, opaques
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
for _, rulename in pairs(rulenames) do
|
for _, rulename in pairs(rulenames) do
|
||||||
if os then rulename.opaquespread=os end
|
if os then rulename.opaquespread=os end
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "receptor_on-> ".."np="..mesecon.postostring(np).." link="..mesecon.tabletostring(rulename).. " v=" .. (voltage or "nil"))
|
|
||||||
mesecon.turnon(np, rulename, voltage)
|
mesecon.turnon(np, rulename, voltage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -347,18 +347,15 @@ function mesecon.get_conductor_off(node_on, rulename)
|
||||||
local conductor = mesecon.get_conductor(node_on.name)
|
local conductor = mesecon.get_conductor(node_on.name)
|
||||||
if conductor then
|
if conductor then
|
||||||
if conductor.offstate then
|
if conductor.offstate then
|
||||||
minetest.log("action", "get_conductor_off1: " .. conductor.offstate)
|
|
||||||
return conductor.offstate
|
return conductor.offstate
|
||||||
end
|
end
|
||||||
if conductor.states then
|
if conductor.states then
|
||||||
local bit = mesecon.rule2bit(rulename, mesecon.conductor_get_rules(node_on))
|
local bit = mesecon.rule2bit(rulename, mesecon.conductor_get_rules(node_on))
|
||||||
local binstate = mesecon.getbinstate(node_on.name, conductor.states)
|
local binstate = mesecon.getbinstate(node_on.name, conductor.states)
|
||||||
binstate = mesecon.set_bit(binstate, bit, "0")
|
binstate = mesecon.set_bit(binstate, bit, "0")
|
||||||
minetest.log("action", "get_conductor_off2: " .. conductor.states[tonumber(binstate,2)+1])
|
|
||||||
return conductor.states[tonumber(binstate,2)+1]
|
return conductor.states[tonumber(binstate,2)+1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.log("action", "get_conductor_off3: " .. conductor.onstate)
|
|
||||||
return conductor.onstate
|
return conductor.onstate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -401,10 +398,8 @@ end
|
||||||
-- looked at, activating / changing all effectors along the way.
|
-- looked at, activating / changing all effectors along the way.
|
||||||
function mesecon.turnon(pos, link, voltage)
|
function mesecon.turnon(pos, link, voltage)
|
||||||
voltage = voltage or 15
|
voltage = voltage or 15
|
||||||
minetest.log("action", pos.x .. "/" .. pos.y .. "/" .. pos.z .. "-->" .. "turnon.voltage.input2="..voltage)
|
|
||||||
|
|
||||||
local pn = get_node_force(pos)
|
local pn = get_node_force(pos)
|
||||||
--if pn and minetest.get_item_group(pn.name, "opaque") == 1 then link.spread=true end
|
|
||||||
local frontiers = {{pos = pos, link = link, voltage = voltage}}
|
local frontiers = {{pos = pos, link = link, voltage = voltage}}
|
||||||
|
|
||||||
local depth = 1
|
local depth = 1
|
||||||
|
@ -412,107 +407,66 @@ function mesecon.turnon(pos, link, voltage)
|
||||||
local f = table.remove(frontiers, 1)
|
local f = table.remove(frontiers, 1)
|
||||||
local node = get_node_force(f.pos)
|
local node = get_node_force(f.pos)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--if node and mesecon.is_conductor_off(node, f.link) then
|
|
||||||
if node and mesecon.is_conductor(node.name) and (f.link.spread==nil and true or f.link.spread) then
|
if node and mesecon.is_conductor(node.name) and (f.link.spread==nil and true or f.link.spread) then
|
||||||
|
|
||||||
--neue spannung berechnen
|
--neue spannung berechnen
|
||||||
local meta = minetest.get_meta(f.pos)
|
local meta = minetest.get_meta(f.pos)
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "-->" .. "turnon.f.link-> ".. mesecon.tabletostring(f.link).. " v=" .. f.voltage)
|
|
||||||
|
|
||||||
local old_v = (mesecon.is_conductor_off(node, f.link) and 0 or meta:get_int("mesecon_voltage"))
|
local old_v = (mesecon.is_conductor_off(node, f.link) and 0 or meta:get_int("mesecon_voltage"))
|
||||||
|
|
||||||
local v = math.max(f.voltage, old_v)
|
local v = math.max(f.voltage, old_v)
|
||||||
--wenn spannung geändert
|
--wenn spannung geändert
|
||||||
--wenn gleiche spannung, aber muss ausgeschalten werden
|
--wenn gleiche spannung, aber muss ausgeschalten werden
|
||||||
--if v~=old_v or (v<1 and mesecon.is_conductor_on(node, f.link)) or (meta:get_int("mesecon_voltage")<0) then
|
|
||||||
if v~=old_v or (v<1 and mesecon.is_conductor_on(node, f.link)) then
|
if v~=old_v or (v<1 and mesecon.is_conductor_on(node, f.link)) then
|
||||||
--minetest.log("action", f.pos.x .. "/" .. f.pos.y .. "/" .. f.pos.z .. "-->" .. "turnon.f.voltage="..f.voltage.."<-->"..v)
|
|
||||||
|
|
||||||
--if v>0 or (v<1 and mesecon.is_conductor_on(node, f.link)) or (meta:get_int("mesecon_voltage")<0) then
|
|
||||||
if v>=1 or (v<1 and mesecon.is_conductor_on(node, f.link)) then
|
if v>=1 or (v<1 and mesecon.is_conductor_on(node, f.link)) then
|
||||||
-- Call turnon on neighbors
|
-- Call turnon on neighbors
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
for _, r in pairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in pairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
for _, l in pairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
for _, l in pairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--aktuelle spannung an nachbarn übergeben
|
--aktuelle spannung an nachbarn übergeben
|
||||||
|
|
||||||
--wenn nachbar wire -> v-1 sonst v
|
--wenn nachbar wire -> v-1 sonst v
|
||||||
local nnode = get_node_force(np)
|
local nnode = get_node_force(np)
|
||||||
if mesecon.is_conductor(nnode.name) then
|
if mesecon.is_conductor(nnode.name) then
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "-->" .. "turnon.insert-> ".. mesecon.postostring(np) .. " link="..mesecon.tabletostring(l).. " v=" .. (v-1).. " nnode.name="..nnode.name)
|
|
||||||
insert(frontiers, {pos = np, link = l, voltage=v-1 ,source=f.pos})
|
insert(frontiers, {pos = np, link = l, voltage=v-1 ,source=f.pos})
|
||||||
else
|
else
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "-->" .. "turnon.insert-> ".. mesecon.postostring(np) .. " link="..mesecon.tabletostring(l).. " v=" .. v.. " nnode.name="..nnode.name)
|
|
||||||
insert(frontiers, {pos = np, link = l, voltage=v ,source=f.pos})
|
insert(frontiers, {pos = np, link = l, voltage=v ,source=f.pos})
|
||||||
end
|
end
|
||||||
|
|
||||||
--insert(frontiers, {pos = np, link = l})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--spannung setzen
|
--spannung setzen
|
||||||
--minetest.log("action", f.pos.x .. "/" .. f.pos.y .. "/" .. f.pos.z .. "-->" .. v)
|
|
||||||
if v<1 then
|
if v<1 then
|
||||||
-- ich bin aus
|
-- ich bin aus
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.off: "..mesecon.get_conductor_off(node, f.link))
|
|
||||||
|
|
||||||
|
|
||||||
--mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
|
||||||
if mesecon.is_conductor_on(node, f.link) then
|
if mesecon.is_conductor_on(node, f.link) then
|
||||||
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
||||||
end
|
end
|
||||||
|
|
||||||
meta:set_int("mesecon_voltage", 0)
|
meta:set_int("mesecon_voltage", 0)
|
||||||
else
|
else
|
||||||
if mesecon.is_conductor_on(node, f.link) then
|
if mesecon.is_conductor_off(node, f.link) then
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.onon: ".. node.name .. "v=".. v)
|
|
||||||
else
|
|
||||||
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.on: "..mesecon.get_conductor_on(node, f.link).." v="..v)
|
|
||||||
end
|
end
|
||||||
meta:set_int("mesecon_voltage", v)
|
meta:set_int("mesecon_voltage", v)
|
||||||
--minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.on.mesecon_voltage: ".. meta:get_int("mesecon_voltage"))
|
|
||||||
|
|
||||||
end
|
end
|
||||||
f.voltage = (v<1 and 0 or v)
|
f.voltage = (v<1 and 0 or v)
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon: f->".. mesecon.tabletostring(f) .. " -> " .. tostring(v<1 and 0 or v))
|
|
||||||
else
|
else
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "-->" .. "turnon.f.voltage="..f.voltage.."<-->"..v .. ":" .. old_v .. " unveraendert")
|
|
||||||
|
|
||||||
if v<1 then
|
if v<1 then
|
||||||
--ausschalten
|
--ausschalten
|
||||||
if mesecon.is_conductor_on(node, f.link) then
|
if mesecon.is_conductor_on(node, f.link) then
|
||||||
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--anschalten
|
|
||||||
--mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
--mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
f.link.opaquespread=false
|
f.link.opaquespread=false
|
||||||
elseif mesecon.is_effector(node.name) then
|
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))
|
|
||||||
|
|
||||||
if f.voltage<1 then
|
if f.voltage<1 then
|
||||||
--ausschalten
|
--ausschalten
|
||||||
--if mesecon.is_effector_on(node.name) then
|
--if mesecon.is_effector_on(node.name) then
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "--> turnon.is_effector_on: f->".. mesecon.tabletostring(f))
|
|
||||||
mesecon.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
|
mesecon.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
|
||||||
mesecon.deactivate(f.pos, node, f.link, depth)
|
mesecon.deactivate(f.pos, node, f.link, depth)
|
||||||
--end
|
--end
|
||||||
else
|
else
|
||||||
--einschalten
|
--einschalten
|
||||||
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.changesignal(f.pos, node, f.link, mesecon.state.on, depth)
|
||||||
mesecon.activate(f.pos, node, f.link, depth)
|
mesecon.activate(f.pos, node, f.link, depth)
|
||||||
end
|
end
|
||||||
|
@ -526,14 +480,10 @@ function mesecon.turnon(pos, link, voltage)
|
||||||
for _, l in pairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
for _, l in pairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
local nlink = copy(l)
|
local nlink = copy(l)
|
||||||
if not (f.link.opaquespread and mesecon.is_conductor(mesecon.get_node_force(np).name)) then nlink.spread = false end
|
if not (f.link.opaquespread and mesecon.is_conductor(mesecon.get_node_force(np).name)) then nlink.spread = false end
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(f.pos) .. "-->" .. "turnon.insert.spread-> ".. mesecon.postostring(np).." ".. mesecon.get_node_force(np).name .. " link="..mesecon.tabletostring(nlink).. " v=" .. f.voltage)
|
|
||||||
insert(frontiers, {pos = np, link = nlink, voltage=f.voltage})
|
insert(frontiers, {pos = np, link = nlink, voltage=f.voltage})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -570,7 +520,6 @@ function mesecon.turnoff(pos, link)
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
for _, r in pairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in pairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.insert_rec_on0-> ".. mesecon.postostring(f.pos) .. " rule="..mesecon.tabletostring(r))
|
|
||||||
-- Check if an onstate receptor is connected. If that is the case,
|
-- Check if an onstate receptor is connected. If that is the case,
|
||||||
-- abort this turnoff process by returning false. `receptor_off` will
|
-- abort this turnoff process by returning false. `receptor_off` will
|
||||||
-- discard all the changes that we made in the voxelmanip:
|
-- discard all the changes that we made in the voxelmanip:
|
||||||
|
@ -593,7 +542,7 @@ function mesecon.turnoff(pos, link)
|
||||||
--if mesecon.is_conductor_on(node, f.link) then
|
--if mesecon.is_conductor_on(node, f.link) then
|
||||||
--spannung neu rechnen
|
--spannung neu rechnen
|
||||||
--else
|
--else
|
||||||
--erstmal spannung überall auf 0 -> wird im anschluss von de receptoren ausgehend wieder gesetzt
|
--erstmal spannung überall auf 0 -> wird im anschluss von den receptoren ausgehend wieder gesetzt
|
||||||
meta:set_int("mesecon_voltage", 0)
|
meta:set_int("mesecon_voltage", 0)
|
||||||
--end
|
--end
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
|
@ -612,7 +561,6 @@ function mesecon.turnoff(pos, link)
|
||||||
for _, r in pairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do
|
for _, r in pairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
local n = get_node_force(np)
|
local n = get_node_force(np)
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rule2meta-> ".. mesecon.postostring(np) .. " link="..mesecon.tabletostring(r).. " name=" .. n.name)
|
|
||||||
if n and is_receptor_on(n.name) and mesecon.get_receptor(n.name).opaquespread then
|
if n and is_receptor_on(n.name) and mesecon.get_receptor(n.name).opaquespread then
|
||||||
local receptorrules = receptor_get_rules(n)
|
local receptorrules = receptor_get_rules(n)
|
||||||
for _, rr in pairs(receptorrules) do
|
for _, rr in pairs(receptorrules) do
|
||||||
|
@ -631,23 +579,17 @@ function mesecon.turnoff(pos, link)
|
||||||
elseif mesecon.is_conductor_on(n) and f.link.opaquespread then
|
elseif mesecon.is_conductor_on(n) and f.link.opaquespread then
|
||||||
insert(frontiers, {pos = np, link = r})
|
insert(frontiers, {pos = np, link = r})
|
||||||
end
|
end
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rule2meta-> ".. " rec_on="..mesecon.tabletostring(rec_on))
|
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rule2meta-> ".. " signals="..mesecon.tabletostring(signals))
|
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rule2meta-> ".. " frontiers="..mesecon.tabletostring(frontiers))
|
|
||||||
for _, l in pairs(mesecon.rules_link_rule_all(fpos, r)) do
|
for _, l in pairs(mesecon.rules_link_rule_all(fpos, r)) do
|
||||||
local lp = vector.add(np, l)
|
local lp = vector.add(np, l)
|
||||||
local ln = get_node_force(lp)
|
local ln = get_node_force(lp)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rules_link_rule_all-> ".. mesecon.postostring(lp) .. " link="..mesecon.tabletostring(l).. " name=" .. ln.name.." os="..tostring(f.link.opaquespread))
|
|
||||||
if mesecon.is_effector(ln.name) then
|
if mesecon.is_effector(ln.name) then
|
||||||
local nlink = copy(l)
|
local nlink = copy(l)
|
||||||
if not f.link.opaquespread then nlink.spread = false end
|
if not f.link.opaquespread then nlink.spread = false end
|
||||||
insert(frontiers, {pos = np, link = nlink})
|
insert(frontiers, {pos = np, link = nlink})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "turnoff.rule2meta-> ".. " frontiers="..mesecon.tabletostring(frontiers))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -733,7 +675,6 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
|
||||||
local function power_walk(pos, home_pos, sourcepos, rulenames, rule, depth, voltage, fc, os)
|
local function power_walk(pos, home_pos, sourcepos, rulenames, rule, depth, voltage, fc, os)
|
||||||
local spread = false
|
local spread = false
|
||||||
local cond = fc
|
local cond = fc
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "power_walk.rulenames=" .. mesecon.tabletostring(rulenames))
|
|
||||||
for _, rname in pairs(rulenames) do
|
for _, rname in pairs(rulenames) do
|
||||||
local np = vector.add(pos, rname)
|
local np = vector.add(pos, rname)
|
||||||
local nn = get_node_force(np)
|
local nn = get_node_force(np)
|
||||||
|
@ -749,21 +690,12 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
|
||||||
local meta = minetest.get_meta(np)
|
local meta = minetest.get_meta(np)
|
||||||
|
|
||||||
local nvol = meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15
|
local nvol = meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.voltage0=" .. voltage.."<-->"..nvol)
|
|
||||||
if nvol>voltage then
|
if nvol>voltage then
|
||||||
voltage = nvol
|
voltage = nvol
|
||||||
cond = mesecon.is_conductor(nn.name)
|
cond = mesecon.is_conductor(nn.name)
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.cond0=" .. tostring(cond))
|
|
||||||
end
|
end
|
||||||
os = os or mesecon.is_receptor_opaquespread(nn.name)
|
os = os or mesecon.is_receptor_opaquespread(nn.name)
|
||||||
--voltage = math.max(voltage, nvol)
|
|
||||||
|
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.voltage1=" .. meta:get_string("mesecon_voltage"))
|
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.voltage2=" .. (meta:get_string("mesecon_voltage")~="" and meta:get_int("mesecon_voltage") or 15))
|
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.voltage3=" .. voltage.." "..nn.name.." "..tostring(mesecon.is_conductor(nn.name))..tostring(os))
|
|
||||||
|
|
||||||
np.opaquespread=mesecon.is_receptor_opaquespread(nn.name)
|
np.opaquespread=mesecon.is_receptor_opaquespread(nn.name)
|
||||||
|
|
||||||
insert(sourcepos, np)
|
insert(sourcepos, np)
|
||||||
if spread_tmp then spread = true end
|
if spread_tmp then spread = true end
|
||||||
end
|
end
|
||||||
|
@ -772,7 +704,6 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
|
||||||
end
|
end
|
||||||
--elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 and not pos.conductor then
|
--elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 and not pos.conductor then
|
||||||
elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then
|
elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.elseif.is_conductor=" .. tostring(mesecon.is_conductor(pos)))
|
|
||||||
local more_sourcepos, more_spread, more_voltage, more_cond, more_os = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos, os)
|
local more_sourcepos, more_spread, more_voltage, more_cond, more_os = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos, os)
|
||||||
if more_sourcepos and #more_sourcepos > 0 and more_voltage>=1 and (not pos.conductor or more_os) then
|
if more_sourcepos and #more_sourcepos > 0 and more_voltage>=1 and (not pos.conductor or more_os) then
|
||||||
mesecon.mergetable(sourcepos, more_sourcepos)
|
mesecon.mergetable(sourcepos, more_sourcepos)
|
||||||
|
@ -780,12 +711,10 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
|
||||||
voltage = more_voltage
|
voltage = more_voltage
|
||||||
cond = more_cond
|
cond = more_cond
|
||||||
os=more_os
|
os=more_os
|
||||||
--minetest.log("action", mesecon.postostring(np) .. "-->" .. "power_walk.cond1=" .. tostring(cond))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "power_walk.cond2=" .. tostring(cond).." opaquespread="..tostring(os).." depth="..tostring(depth))
|
|
||||||
return sourcepos, spread, voltage, cond, os
|
return sourcepos, spread, voltage, cond, os
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -812,10 +741,8 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
|
||||||
|
|
||||||
|
|
||||||
if (#sourcepos == 0) then
|
if (#sourcepos == 0) then
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "is_powered.voltage4=" .. "0")
|
|
||||||
return false, false, 0, false, false
|
return false, false, 0, false, false
|
||||||
else
|
else
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "is_powered.voltage5=" .. v .. " fC="..tostring(fromConductor).." spread="..tostring(spread).." os="..tostring(opaquespread))
|
|
||||||
return sourcepos, spread, v, fromConductor, opaquespread
|
return sourcepos, spread, v, fromConductor, opaquespread
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,6 @@ function mesecon.on_placenode(pos, node)
|
||||||
|
|
||||||
-- Receptors: Send on signal when active
|
-- Receptors: Send on signal when active
|
||||||
if mesecon.is_receptor_on(node.name) then
|
if mesecon.is_receptor_on(node.name) then
|
||||||
--nach spannung fragen
|
|
||||||
mesecon.receptor_on(pos, mesecon.receptor_get_rules(node))
|
mesecon.receptor_on(pos, mesecon.receptor_get_rules(node))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,12 +23,9 @@ function mesecon.on_placenode(pos, node)
|
||||||
node = mesecon.get_node_force(pos)
|
node = mesecon.get_node_force(pos)
|
||||||
pos.conductor=true
|
pos.conductor=true
|
||||||
local sources, _, voltage, fromConductor = mesecon.is_powered(pos)
|
local sources, _, voltage, fromConductor = mesecon.is_powered(pos)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_placenode.voltage=" .. voltage .. " fC="..tostring(fromConductor))
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_placenode.sources=" .. mesecon.tabletostring(sources))
|
|
||||||
if sources and voltage>=1 then
|
if sources and voltage>=1 then
|
||||||
|
|
||||||
voltage = fromConductor and voltage-1 or voltage
|
voltage = fromConductor and voltage-1 or voltage
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_placenode.voltage2=" .. voltage )
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("mesecon_voltage", voltage)
|
meta:set_int("mesecon_voltage", voltage)
|
||||||
|
|
||||||
|
@ -37,13 +33,7 @@ function mesecon.on_placenode(pos, node)
|
||||||
-- conductors will be activated (when pushing an on-conductor with a piston)
|
-- conductors will be activated (when pushing an on-conductor with a piston)
|
||||||
for _, s in ipairs(sources) do
|
for _, s in ipairs(sources) do
|
||||||
local rule = vector.subtract(pos, s)
|
local rule = vector.subtract(pos, s)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. " on_placenode.for_turnon1=" .. mesecon.tabletostring(rule) .. " v=" ..(voltage))
|
|
||||||
|
|
||||||
local nnode = mesecon.get_node_force(s)
|
local nnode = mesecon.get_node_force(s)
|
||||||
|
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. " on_placenode.for_turnon2=" .. mesecon.tabletostring(s) .. " nnode.name=" ..nnode.name)
|
|
||||||
|
|
||||||
mesecon.turnon(pos, rule, voltage)
|
mesecon.turnon(pos, rule, voltage)
|
||||||
end
|
end
|
||||||
mesecon.receptor_on (pos, mesecon.conductor_get_rules(node), voltage-1)
|
mesecon.receptor_on (pos, mesecon.conductor_get_rules(node), voltage-1)
|
||||||
|
@ -54,7 +44,6 @@ function mesecon.on_placenode(pos, node)
|
||||||
|
|
||||||
-- Effectors: Send changesignal and activate or deactivate
|
-- Effectors: Send changesignal and activate or deactivate
|
||||||
if mesecon.is_effector(node.name) then
|
if mesecon.is_effector(node.name) then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. " on_placenode.is_effector")
|
|
||||||
local powered_rules = {}
|
local powered_rules = {}
|
||||||
local unpowered_rules = {}
|
local unpowered_rules = {}
|
||||||
|
|
||||||
|
@ -81,8 +70,6 @@ function mesecon.on_placenode(pos, node)
|
||||||
|
|
||||||
if minetest.get_item_group(node.name, "opaque") == 1 then
|
if minetest.get_item_group(node.name, "opaque") == 1 then
|
||||||
local is_powered, direct_source, voltage, _, opaquespread = mesecon.is_powered(pos)
|
local is_powered, direct_source, voltage, _, opaquespread = mesecon.is_powered(pos)
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. " on_placenode.is_powered="..mesecon.tabletostring(is_powered))
|
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. " on_placenode.opaquespread="..tostring(opaquespread))
|
|
||||||
if is_powered and direct_source then
|
if is_powered and direct_source then
|
||||||
if opaquespread then
|
if opaquespread then
|
||||||
mesecon.receptor_on(pos, nil, voltage)
|
mesecon.receptor_on(pos, nil, voltage)
|
||||||
|
@ -93,41 +80,15 @@ function mesecon.on_placenode(pos, node)
|
||||||
local npos = neighbors[n].pos
|
local npos = neighbors[n].pos
|
||||||
local nnode = minetest.get_node(npos)
|
local nnode = minetest.get_node(npos)
|
||||||
if mesecon.is_conductor_off(nnode) and opaquespread then
|
if mesecon.is_conductor_off(nnode) and opaquespread then
|
||||||
minetest.log("action", mesecon.postostring(npos) .. "-->" .. " on_placenode.is_conductor_off"
|
|
||||||
.. " name="..nnode.name
|
|
||||||
.. " effoff="..tostring(mesecon.is_effector_off(nnode.name))
|
|
||||||
.. " redtorch="..tostring(minetest.get_item_group(nnode.name, "redstone_torch"))
|
|
||||||
.. " opaquespread=" .. tostring(opaquespread)
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Redstone torch is a special case and must be ignored
|
-- Redstone torch is a special case and must be ignored
|
||||||
elseif mesecon.is_effector_off(nnode.name) and minetest.get_item_group(nnode.name, "redstone_torch") == 0 then
|
elseif mesecon.is_effector_off(nnode.name) and minetest.get_item_group(nnode.name, "redstone_torch") == 0 then
|
||||||
minetest.log("action", mesecon.postostring(npos) .. "-->" .. " on_placenode.is_effector_off"
|
|
||||||
.. " name="..nnode.name
|
|
||||||
.. " effoff="..tostring(mesecon.is_effector_off(nnode.name))
|
|
||||||
.. " redtorch="..tostring(minetest.get_item_group(nnode.name, "redstone_torch"))
|
|
||||||
.. " opaquespread=" .. tostring(opaquespread)
|
|
||||||
)
|
|
||||||
mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
|
mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
|
||||||
mesecon.activate(npos, nnode, neighbors[n].link, 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
|
elseif mesecon.is_effector(nnode.name) and minetest.get_item_group(nnode.name, "redstone_torch") == 0 then
|
||||||
--eigen funktion für comparator schreiben
|
--eigen funktion für comparator schreiben
|
||||||
minetest.log("action", mesecon.postostring(npos) .. "-->" .. " on_placenode.is_comparator_off"
|
|
||||||
.. " name="..nnode.name
|
|
||||||
.. " effoff="..tostring(mesecon.is_effector_off(nnode.name))
|
|
||||||
.. " redtorch="..tostring(minetest.get_item_group(nnode.name, "redstone_torch"))
|
|
||||||
.. " opaquespread=" .. tostring(opaquespread)
|
|
||||||
)
|
|
||||||
|
|
||||||
minetest.log("action", mesecon.postostring(npos) .. "--> on_placenode.is_effector: node.name->"..nnode.name)
|
|
||||||
|
|
||||||
if voltage<1 then
|
if voltage<1 then
|
||||||
--ausschalten
|
|
||||||
--if mesecon.is_effector_on(node.name) then
|
--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.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
|
||||||
--mesecon.deactivate(f.pos, node, f.link, depth)
|
--mesecon.deactivate(f.pos, node, f.link, depth)
|
||||||
|
|
||||||
|
@ -135,8 +96,6 @@ function mesecon.on_placenode(pos, node)
|
||||||
mesecon.deactivate(npos, nnode, neighbors[n].link, 1)
|
mesecon.deactivate(npos, nnode, neighbors[n].link, 1)
|
||||||
--end
|
--end
|
||||||
else
|
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.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1)
|
||||||
mesecon.activate(npos, nnode, neighbors[n].link, 1)
|
mesecon.activate(npos, nnode, neighbors[n].link, 1)
|
||||||
end
|
end
|
||||||
|
@ -151,10 +110,8 @@ function mesecon.on_dignode(pos, node, direct_dig)
|
||||||
local regnode = minetest.registered_nodes[node.name]
|
local regnode = minetest.registered_nodes[node.name]
|
||||||
if (regnode and regnode.mesecons and not regnode.on_destruct) or not direct_dig then
|
if (regnode and regnode.mesecons and not regnode.on_destruct) or not direct_dig then
|
||||||
if mesecon.is_conductor_on(node) then
|
if mesecon.is_conductor_on(node) then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_dignode.is_conductor_on")
|
|
||||||
mesecon.conductor_off(pos, mesecon.conductor_get_rules(node))
|
mesecon.conductor_off(pos, mesecon.conductor_get_rules(node))
|
||||||
elseif mesecon.is_receptor_on(node.name) then
|
elseif mesecon.is_receptor_on(node.name) then
|
||||||
minetest.log("action", mesecon.postostring(pos) .. "-->" .. "on_dignode.is_receptor_on")
|
|
||||||
mesecon.receptor_off(pos, mesecon.receptor_get_rules(node), mesecon.is_receptor_opaquespread(node.name))
|
mesecon.receptor_off(pos, mesecon.receptor_get_rules(node), mesecon.is_receptor_opaquespread(node.name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ local wire_rules = {
|
||||||
local function wire_getconnect(from_pos, self_pos, from_rule)
|
local function wire_getconnect(from_pos, self_pos, from_rule)
|
||||||
local node = minetest.get_node(self_pos)
|
local node = minetest.get_node(self_pos)
|
||||||
if minetest.registered_nodes[node.name]
|
if minetest.registered_nodes[node.name]
|
||||||
and minetest.registered_nodes[node.name].mesecons or minetest.get_item_group(node.name, "opaque") == 1 then
|
and minetest.registered_nodes[node.name].mesecons or minetest.get_item_group(node.name, "opaque") == 1 then
|
||||||
-- rules of node to possibly connect to
|
-- rules of node to possibly connect to
|
||||||
local rules
|
local rules
|
||||||
if (minetest.registered_nodes[node.name].mesecon_wire) then
|
if (minetest.registered_nodes[node.name].mesecon_wire) then
|
||||||
|
@ -128,7 +128,6 @@ local function wire_updateconnect(pos)
|
||||||
--check all rules
|
--check all rules
|
||||||
for _, r in ipairs(wire_rules) do
|
for _, r in ipairs(wire_rules) do
|
||||||
local res, val = wire_getconnect(pos, vector.add(pos, r), r)
|
local res, val = wire_getconnect(pos, vector.add(pos, r), r)
|
||||||
--minetest.log("action", mesecon.postostring(pos) .. "-->" .. "wire_updateconnect->" .. " self_pos="..mesecon.postostring(vector.add(pos, r)) .. " " .. tostring(res).." "..tostring (val))
|
|
||||||
if res then
|
if res then
|
||||||
table.insert(connections, r)
|
table.insert(connections, r)
|
||||||
end
|
end
|
||||||
|
@ -193,7 +192,6 @@ local function update_on_place_dig(pos, node)
|
||||||
local nnode = minetest.get_node(np).name
|
local nnode = minetest.get_node(np).name
|
||||||
if minetest.registered_nodes[nnode] and minetest.registered_nodes[nnode].mesecon_wire then
|
if minetest.registered_nodes[nnode] and minetest.registered_nodes[nnode].mesecon_wire then
|
||||||
local abandoned_rules = wire_updateconnect(np)
|
local abandoned_rules = wire_updateconnect(np)
|
||||||
minetest.log("action", mesecon.postostring(np) .. "-->" .. "wire.update_on_place_dig->" .. mesecon.tabletostring(abandoned_rules))
|
|
||||||
if next(abandoned_rules) ~= nil then
|
if next(abandoned_rules) ~= nil then
|
||||||
mesecon.conductor_off(np, abandoned_rules)
|
mesecon.conductor_off(np, abandoned_rules)
|
||||||
mesecon.conductor_off(np, mesecon.conductor_get_rules(minetest.get_node(np)))
|
mesecon.conductor_off(np, mesecon.conductor_get_rules(minetest.get_node(np)))
|
||||||
|
@ -437,16 +435,13 @@ local function register_wires2()
|
||||||
|
|
||||||
|
|
||||||
--rules berechnen, nur nötige verwenden
|
--rules berechnen, nur nötige verwenden
|
||||||
--minetest.log("action", "register_wires2 -> ".. nodeid .. " wire_rules=" .. mesecon.tabletostring(wire_rules))
|
|
||||||
local nrules = {}
|
local nrules = {}
|
||||||
for i=0,11 do
|
for i=0,11 do
|
||||||
if nid[i]==1 then
|
if nid[i]==1 then
|
||||||
--minetest.log("action", "register_wires2 -> ".. nodeid .. " i=" .. tostring(i).." -> "..mesecon.tabletostring(wire_rules[i]))
|
|
||||||
table.insert(nrules,wire_rules[i+1])
|
table.insert(nrules,wire_rules[i+1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(nrules,wire_rules[12+1]) --ym (always)
|
table.insert(nrules,wire_rules[12+1]) --ym (always)
|
||||||
--minetest.log("action", "register_wires2 -> ".. nodeid .. " rules=" .. mesecon.tabletostring(nrules))
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
00100000
|
00100000
|
||||||
|
|
Loading…
Reference in New Issue