From c4ec520986d4f636da63ae81917a52e2282f2cd0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 02:19:52 +0100 Subject: [PATCH 01/27] Fix redstone torch rules --- mods/ITEMS/REDSTONE/mesecons_torch/init.lua | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua index 865c8e48..579f1c1d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua @@ -16,16 +16,7 @@ local rotate_torch_rules = function (rules, param2) end end -local torch_get_output_rules = function(node) - local rules = { - {x = 1, y = 0, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 0, y = 0, z =-1}, - {x = 0, y = 1, z = 0}, - {x = 0, y =-1, z = 0}} - - return rotate_torch_rules(rules, node.param2) -end +local torch_get_output_rules = mesecon.rules.alldirs local torch_get_input_rules = function(node) local rules = {{x = -2, y = 0, z = 0}, From f72717e8de0c9bf05c62717187dbeaad5a313690 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 02:20:07 +0100 Subject: [PATCH 02/27] Support powering of opaque blocks (WIP) --- mods/ITEMS/REDSTONE/mesecons/init.lua | 20 +++++++ mods/ITEMS/REDSTONE/mesecons/internal.lua | 13 +++-- mods/ITEMS/REDSTONE/mesecons/presets.lua | 70 +++++++++++------------ mods/ITEMS/REDSTONE/mesecons/util.lua | 19 ++++++ 4 files changed, 83 insertions(+), 39 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/init.lua b/mods/ITEMS/REDSTONE/mesecons/init.lua index 83e611b5..57b17b5b 100644 --- a/mods/ITEMS/REDSTONE/mesecons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons/init.lua @@ -81,6 +81,13 @@ mesecon.queue:add_function("receptor_on", function (pos, rules) for _, rulename in ipairs(rulenames) do mesecon.turnon(np, rulename) end + if rule.spread then + if minetest.get_item_group(minetest.get_node(np).name, "opaque") == 1 then + for _, neighbor in ipairs(mesecon.mcl_get_neighbors(np)) do + mesecon.turnon(neighbor.pos, vector.add(rule, neighbor.link)) + end + end + end end mesecon.vm_commit() @@ -110,6 +117,19 @@ mesecon.queue:add_function("receptor_off", function (pos, rules) mesecon.vm_abort() end end + if rule.spread then + if minetest.get_item_group(minetest.get_node(np).name, "opaque") == 1 then + for _, neighbor in ipairs(mesecon.mcl_get_neighbors(np)) do + mesecon.vm_begin() + mesecon.changesignal(neighbor.pos, minetest.get_node(neighbor.pos), vector.add(rule, neighbor.link), mesecon.state.off, 2) + if (mesecon.turnoff(neighbor.pos, vector.add(rule, neighbor.link))) then + mesecon.vm_commit() + else + mesecon.vm_abort() + end + end + end + end end end) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index e5ba91eb..3f1fb737 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -398,6 +398,7 @@ function mesecon.turnon(pos, link) mesecon.activate(f.pos, node, f.link, depth) end end + depth = depth + 1 end end @@ -557,7 +558,8 @@ function mesecon.rotate_rules_right(rules) x = -rule.z, y = rule.y, z = rule.x, - name = rule.name}) + name = rule.name, + spread = rule.spread,}) end return nr end @@ -569,7 +571,8 @@ function mesecon.rotate_rules_left(rules) x = rule.z, y = rule.y, z = -rule.x, - name = rule.name}) + name = rule.name, + spread = rule.spread,}) end return nr end @@ -581,7 +584,8 @@ function mesecon.rotate_rules_down(rules) x = -rule.y, y = rule.x, z = rule.z, - name = rule.name}) + name = rule.name, + spread = rule.spread,}) end return nr end @@ -593,7 +597,8 @@ function mesecon.rotate_rules_up(rules) x = rule.y, y = -rule.x, z = rule.z, - name = rule.name}) + name = rule.name, + spread = rule.spread,}) end return nr end diff --git a/mods/ITEMS/REDSTONE/mesecons/presets.lua b/mods/ITEMS/REDSTONE/mesecons/presets.lua index eca3d735..1abaae9b 100644 --- a/mods/ITEMS/REDSTONE/mesecons/presets.lua +++ b/mods/ITEMS/REDSTONE/mesecons/presets.lua @@ -6,6 +6,9 @@ mesecon.rules.default = {x=1, y=0, z=0}, {x=-1, y=0, z=0}, {x=0, y=0, z=1}, + {x=0, y=1, z=0}, + {x=0, y=-1, z=0}, + {x=1, y=1, z=0}, {x=1, y=-1, z=0}, {x=-1, y=1, z=0}, @@ -16,6 +19,37 @@ mesecon.rules.default = {x=0, y=-1, z=-1}} mesecon.rules.alldirs = +{{x= 1, y= 0, z= 0, spread = true}, + {x=-1, y= 0, z= 0, spread = true}, + {x= 0, y= 1, z= 0, spread = true}, + {x= 0, y=-1, z= 0, spread = true}, + {x= 0, y= 0, z= 1, spread = true}, + {x= 0, y= 0, z=-1, spread = true}} + +mesecon.rules.pplate = +{{x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 0, y = 1, z = 0}, + {x = 0, y =-1, z = 0, spread = true}, + {x = 0, y = 0, z = 1}, + {x = 0, y = 0, z =-1}} + +mesecon.rules.buttonlike = +{{x = 0, y = 0, z =-1}, + {x = 0, y = 0, z = 1}, + {x = 0, y =-1, z = 0}, + {x = 0, y = 1, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 1, y = 0, z = 0, spread = true}} + +mesecon.rules.flat = +{{x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 0, y = 0, z = 1}, + {x = 0, y = 0, z =-1}} + +-- NOT IN ORIGNAL MESECONS +mesecon.rules.mcl_alldirs_short = {{x= 1, y= 0, z= 0}, {x=-1, y= 0, z= 0}, {x= 0, y= 1, z= 0}, @@ -23,41 +57,7 @@ mesecon.rules.alldirs = {x= 0, y= 0, z= 1}, {x= 0, y= 0, z=-1}} -mesecon.rules.pplate = -{{x = 1, y = 0, z = 0}, - {x =-1, y = 0, z = 0}, - {x = 0, y = 1, z = 0}, - {x = 0, y =-1, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 0, y = 0, z =-1}, - {x = 0, y = -2, z = 0}, - {x = 1, y = -1, z = 0}, - {x =-1, y = -1, z = 0}, - {x = 0, y = -1, z = 1}, - {x = 0, y = -1, z =-1}} - -mesecon.rules.buttonlike = -{{x = 1, y = 0, z = 0}, - {x = 1, y = 1, z = 0}, - {x = 1, y =-1, z = 0}, - {x = 1, y = 0, z =-1}, - {x = 1, y = 0, z = 1}, - {x = 2, y = 0, z = 0}, - {x = 0, y = 1, z = 0}, - {x = 0, y = -1, z = 0}, - {x =-1, y = 0, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 0, y = 0, z =-1}} - -mesecon.rules.flat = -{{x = 1, y = 0, z = 0}, - {x =-1, y = 0, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 0, y = 0, z =-1}, - {x = 2, y = 0, z = 0}, - {x =-2, y = 0, z = 0}, - {x = 0, y = 0, z = 2}, - {x = 0, y = 0, z =-2}} +-- END OF UNOFFICIAL RULES mesecon.rules.buttonlike_get = function(node) local rules = mesecon.rules.buttonlike diff --git a/mods/ITEMS/REDSTONE/mesecons/util.lua b/mods/ITEMS/REDSTONE/mesecons/util.lua index 39f56968..fc7e1f2e 100644 --- a/mods/ITEMS/REDSTONE/mesecons/util.lua +++ b/mods/ITEMS/REDSTONE/mesecons/util.lua @@ -90,6 +90,25 @@ function mesecon.rule2meta(findrule, allrules) return allrules[index] end +-- Returns the 6 immediate neighbors of pos +-- (nodes which touch the sides of pos). +-- NOT PART OF ORIGINAL MESECONS! +function mesecon.mcl_get_neighbors(pos) + local r = { + { x= 0, y= 0, z=-1 }, + { x= 0, y= 0, z= 1 }, + { x= 0, y=-1, z= 0 }, + { x= 0, y= 1, z= 0 }, + { x=-1, y= 0, z= 0 }, + { x= 1, y= 0, z= 0 }, + } + local e = {} + for i=1, #r do + table.insert(e, { pos = vector.add(pos, r[i]), link = r[i] }) + end + return e +end + function mesecon.dec2bin(n) local x, y = math.floor(n / 2), n % 2 if (n > 1) then From 7626102bdb99b33a540bc050c980d8b667ccc4ae Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 03:15:32 +0100 Subject: [PATCH 03/27] Fix dispenser inventory not getting set if up/down --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 0d1ac1d9..ba461fc2 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -35,9 +35,9 @@ local orientate_dispenser = function(pos, placer) local node = minetest.get_node(pos) if pitch > 55 then - minetest.set_node(pos, {name="mcl_dispensers:dispenser_up", param2 = node.param2}) + minetest.swap_node(pos, {name="mcl_dispensers:dispenser_up", param2 = node.param2}) elseif pitch < -55 then - minetest.set_node(pos, {name="mcl_dispensers:dispenser_down", param2 = node.param2}) + minetest.swap_node(pos, {name="mcl_dispensers:dispenser_down", param2 = node.param2}) end end From f612d1b584b5cfa804271e033eefe68fb79671d4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 03:37:41 +0100 Subject: [PATCH 04/27] Rework core rules of most redstone components --- mods/ENTITIES/mcl_minecarts/rails.lua | 10 ++++++ mods/ITEMS/REDSTONE/mcl_comparators/init.lua | 2 +- mods/ITEMS/REDSTONE/mcl_observers/init.lua | 24 +++++-------- mods/ITEMS/REDSTONE/mesecons/presets.lua | 26 +++++++------- mods/ITEMS/REDSTONE/mesecons_delayer/init.lua | 2 +- .../REDSTONE/mesecons_solarpanel/init.lua | 35 +++++++++---------- mods/ITEMS/REDSTONE/mesecons_wires/init.lua | 24 ++++++------- mods/ITEMS/mcl_chests/init.lua | 8 +---- 8 files changed, 64 insertions(+), 67 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index a25971eb..570440ef 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -53,7 +53,9 @@ register_rail("mcl_minecarts:golden_rail", mesecons = { conductor = { state = mesecon.state.off, + offstate = "mcl_minecarts:golden_rail", onstate = "mcl_minecarts:golden_rail_on", + rules = mesecon.rules.alldirs, }, }, } @@ -69,6 +71,8 @@ register_rail("mcl_minecarts:golden_rail_on", conductor = { state = mesecon.state.on, offstate = "mcl_minecarts:golden_rail", + onstate = "mcl_minecarts:golden_rail_on", + rules = mesecon.rules.alldirs, }, }, drop = "mcl_minecarts:golden_rail", @@ -87,7 +91,9 @@ register_rail("mcl_minecarts:activator_rail", mesecons = { conductor = { state = mesecon.state.off, + offstate = "mcl_minecarts:activator_rail", onstate = "mcl_minecarts:activator_rail_on", + rules = mesecon.rules.alldirs, }, }, } @@ -102,6 +108,8 @@ register_rail("mcl_minecarts:activator_rail_on", conductor = { state = mesecon.state.on, offstate = "mcl_minecarts:activator_rail", + onstate = "mcl_minecarts:activator_rail_on", + rules = mesecon.rules.alldirs, }, }, drop = "mcl_minecarts:activator_rail", @@ -119,6 +127,7 @@ register_rail("mcl_minecarts:detector_rail", mesecons = { receptor = { state = mesecon.state.off, + rules = mesecon.rules.pplate, }, }, } @@ -132,6 +141,7 @@ register_rail("mcl_minecarts:detector_rail_on", mesecons = { receptor = { state = mesecon.state.on, + rules = mesecon.rules.pplate, }, }, drop = "mcl_minecarts:detector_rail", diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index a4fef7b5..49ea52e6 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -1,7 +1,7 @@ -- Functions that get the input/output rules of the comparator local comparator_get_output_rules = function(node) - local rules = {{x = -1, y = 0, z = 0}} + local rules = {{x = -1, y = 0, z = 0, spread=true}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) end diff --git a/mods/ITEMS/REDSTONE/mcl_observers/init.lua b/mods/ITEMS/REDSTONE/mcl_observers/init.lua index 8b02e2f6..825a8c9a 100644 --- a/mods/ITEMS/REDSTONE/mcl_observers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_observers/init.lua @@ -1,5 +1,5 @@ local rules_flat = { - { x = 0, y = 0, z = -1 }, + { x = 0, y = 0, z = -1, spread = true }, } local get_rules_flat = function(node) local rules = rules_flat @@ -9,8 +9,8 @@ local get_rules_flat = function(node) return rules end -local rules_down = {{ x = 0, y = 1, z = 0 }} -local rules_up = {{ x = 0, y = -1, z = 0 }} +local rules_down = {{ x = 0, y = 1, z = 0, spread = true }} +local rules_up = {{ x = 0, y = -1, z = 0, spread = true }} -- Scan the node in front of the observer -- and update the observer state if needed. @@ -36,13 +36,13 @@ local observer_scan = function(pos, initialize) -- Node state changed! Activate observer if node.name == "mcl_observers:observer_off" then minetest.set_node(pos, {name = "mcl_observers:observer_on", param2 = node.param2}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, get_rules_flat(node)) elseif node.name == "mcl_observers:observer_down_off" then minetest.set_node(pos, {name = "mcl_observers:observer_down_on"}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, rules_down) elseif node.name == "mcl_observers:observer_up_off" then minetest.set_node(pos, {name = "mcl_observers:observer_up_on"}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, rules_up) end meta_needs_updating = true end @@ -58,12 +58,6 @@ end -- Vertical orientation (CURRENTLY DISABLED) local observer_orientate = function(pos, placer) - -- Currently, do nothing. - -- The vertical observers detect the node correctly, but they have problems with - -- transmitting the redstone signal vertically. - -- TODO: Re-enable orientation when vertical observers are done. - do return end - -- Not placed by player if not placer then return end @@ -130,7 +124,7 @@ mesecon.register_node("mcl_observers:observer", on_timer = function(pos, elapsed) local node = minetest.get_node(pos) minetest.set_node(pos, {name = "mcl_observers:observer_off", param2 = node.param2}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, get_rules_flat(node)) end, } ) @@ -179,7 +173,7 @@ mesecon.register_node("mcl_observers:observer_down", on_timer = function(pos, elapsed) local node = minetest.get_node(pos) minetest.set_node(pos, {name = "mcl_observers:observer_down_off", param2 = node.param2}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, rules_down) end, }) @@ -226,7 +220,7 @@ mesecon.register_node("mcl_observers:observer_up", end, on_timer = function(pos, elapsed) minetest.set_node(pos, {name = "mcl_observers:observer_up_off"}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, rules_up) end, }) diff --git a/mods/ITEMS/REDSTONE/mesecons/presets.lua b/mods/ITEMS/REDSTONE/mesecons/presets.lua index 1abaae9b..3d65cfe7 100644 --- a/mods/ITEMS/REDSTONE/mesecons/presets.lua +++ b/mods/ITEMS/REDSTONE/mesecons/presets.lua @@ -19,12 +19,12 @@ mesecon.rules.default = {x=0, y=-1, z=-1}} mesecon.rules.alldirs = -{{x= 1, y= 0, z= 0, spread = true}, - {x=-1, y= 0, z= 0, spread = true}, - {x= 0, y= 1, z= 0, spread = true}, - {x= 0, y=-1, z= 0, spread = true}, - {x= 0, y= 0, z= 1, spread = true}, - {x= 0, y= 0, z=-1, spread = true}} +{{x= 1, y= 0, z= 0}, + {x=-1, y= 0, z= 0}, + {x= 0, y= 1, z= 0}, + {x= 0, y=-1, z= 0}, + {x= 0, y= 0, z= 1}, + {x= 0, y= 0, z=-1}} mesecon.rules.pplate = {{x = 1, y = 0, z = 0}, @@ -49,13 +49,13 @@ mesecon.rules.flat = {x = 0, y = 0, z =-1}} -- NOT IN ORIGNAL MESECONS -mesecon.rules.mcl_alldirs_short = -{{x= 1, y= 0, z= 0}, - {x=-1, y= 0, z= 0}, - {x= 0, y= 1, z= 0}, - {x= 0, y=-1, z= 0}, - {x= 0, y= 0, z= 1}, - {x= 0, y= 0, z=-1}} +mesecon.rules.mcl_alldirs_spread = +{{x= 1, y= 0, z= 0, spread = true}, + {x=-1, y= 0, z= 0, spread = true}, + {x= 0, y= 1, z= 0, spread = true}, + {x= 0, y=-1, z= 0, spread = true}, + {x= 0, y= 0, z= 1, spread = true}, + {x= 0, y= 0, z=-1, spread = true}} -- END OF UNOFFICIAL RULES diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index 32e934bd..fb8a9fde 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -1,6 +1,6 @@ -- Function that get the input/output rules of the delayer local delayer_get_output_rules = function(node) - local rules = {{x = -1, y = 0, z = 0}} + local rules = {{x = -1, y = 0, z = 0, spread=true}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) end diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index 90b9ac95..ec455b53 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -1,6 +1,6 @@ -local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } -- Solar Pannel +local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } --- Solar Panel +-- Daylight Sensor minetest.register_node("mesecons_solarpanel:solar_panel_on", { drawtype = "nodebox", tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png", @@ -25,17 +25,16 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", { sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {receptor = { state = mesecon.state.on, - rules = mesecon.rules.alldirs, + rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, mesecon.rules.pplate) end, _mcl_blast_resistance = 1, _mcl_hardness = 0.2, }) --- Solar Panel minetest.register_node("mesecons_solarpanel:solar_panel_off", { drawtype = "nodebox", tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png", @@ -60,11 +59,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", { sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {receptor = { state = mesecon.state.off, - rules = mesecon.rules.alldirs, + rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, mesecon.rules.pplate) end, _mcl_blast_resistance = 1, _mcl_hardness = 0.2, @@ -89,7 +88,7 @@ minetest.register_abm({ if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, mesecon.rules.pplate) end end, }) @@ -104,14 +103,13 @@ minetest.register_abm({ if light < 12 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, mesecon.rules.pplate) end end, }) ---- Solar panel inversed +--- Inverted Daylight Sensor --- Solar Panel minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", { drawtype = "nodebox", tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png", @@ -135,17 +133,17 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", { _doc_items_create_entry = false, sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {receptor = { - state = mesecon.state.on + state = mesecon.state.on, + rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, mesecon.rules.pplate) end, _mcl_blast_resistance = 1, _mcl_hardness = 0.2, }) --- Solar Panel minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", { drawtype = "nodebox", tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png", @@ -170,11 +168,12 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", { _doc_items_usagehelp = "Rightclick the daylight sensor to turn it into a daylight sensor.", sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {receptor = { - state = mesecon.state.off + state = mesecon.state.off, + rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, mesecon.rules.pplate) end, _mcl_blast_resistance = 1, _mcl_hardness = 0.2, @@ -190,7 +189,7 @@ minetest.register_abm({ if light < 12 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2}) - mesecon.receptor_on(pos) + mesecon.receptor_on(pos, mesecon.rules.pplate) end end, }) @@ -205,7 +204,7 @@ minetest.register_abm({ if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2}) - mesecon.receptor_off(pos) + mesecon.receptor_off(pos, mesecon.rules.pplate) end end, }) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index 2cf8a7ee..52450342 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -164,20 +164,20 @@ local function register_wires() end local rules = {} - if (nid[0] == 1) then table.insert(rules, vector.new( 1, 0, 0)) end - if (nid[1] == 1) then table.insert(rules, vector.new( 0, 0, 1)) end - if (nid[2] == 1) then table.insert(rules, vector.new(-1, 0, 0)) end - if (nid[3] == 1) then table.insert(rules, vector.new( 0, 0, -1)) end + if (nid[0] == 1) then table.insert(rules, {x=1, y= 0,z= 0, spread=true}) end + if (nid[1] == 1) then table.insert(rules, {x=0, y= 0,z= 1, spread=true}) end + if (nid[2] == 1) then table.insert(rules, {x=-1,y= 0,z= 0, spread=true}) end + if (nid[3] == 1) then table.insert(rules, {x= 0,y= 0,z=-1, spread=true}) end - if (nid[0] == 1) then table.insert(rules, vector.new( 1, -1, 0)) end - if (nid[1] == 1) then table.insert(rules, vector.new( 0, -1, 1)) end - if (nid[2] == 1) then table.insert(rules, vector.new(-1, -1, 0)) end - if (nid[3] == 1) then table.insert(rules, vector.new( 0, -1, -1)) end + if (nid[0] == 1) then table.insert(rules, {x= 1,y=-1,z= 0}) end + if (nid[1] == 1) then table.insert(rules, {x= 0,y=-1,z= 1}) end + if (nid[2] == 1) then table.insert(rules, {x=-1,y=-1,z= 0}) end + if (nid[3] == 1) then table.insert(rules, {x= 0,y=-1,z= -1}) end - if (nid[4] == 1) then table.insert(rules, vector.new( 1, 1, 0)) end - if (nid[5] == 1) then table.insert(rules, vector.new( 0, 1, 1)) end - if (nid[6] == 1) then table.insert(rules, vector.new(-1, 1, 0)) end - if (nid[7] == 1) then table.insert(rules, vector.new( 0, 1, -1)) end + if (nid[4] == 1) then table.insert(rules, {x= 1,y= 1,z= 0}) end + if (nid[5] == 1) then table.insert(rules, {x= 0,y= 1,z= 1}) end + if (nid[6] == 1) then table.insert(rules, {x=-1,y= 1,z= 0}) end + if (nid[7] == 1) then table.insert(rules, {x= 0,y= 1,z= -1}) end local meseconspec_off = { conductor = { rules = rules, diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index bc3c6af0..d312a570 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -370,13 +370,7 @@ register_chest("chest", false ) -local trapped_chest_mesecons_rules = { - {x = 1, y = 0, z = 0}, - {x = -1, y = 0, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 0, y = 0, z =-1}, - {x = 0, y =-1, z = 0} -} +local trapped_chest_mesecons_rules = mesecon.rules.pplate register_chest("trapped_chest", "Trapped Chest", From 4f9be588716406583b3b0927585a75cfd6817708 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 04:08:40 +0100 Subject: [PATCH 05/27] Fix incorrect power transmission of buttons --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 51 ----------------- mods/ITEMS/REDSTONE/mesecons/presets.lua | 58 +++++++++++++++----- mods/ITEMS/REDSTONE/mesecons/util.lua | 53 ++++++++++++++++++ mods/ITEMS/REDSTONE/mesecons_button/init.lua | 2 +- mods/ITEMS/REDSTONE/mesecons_torch/init.lua | 4 +- 5 files changed, 100 insertions(+), 68 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 3f1fb737..ffde3b66 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -550,55 +550,4 @@ function mesecon.is_powered(pos, rule) else return sourcepos end end ---Rules rotation Functions: -function mesecon.rotate_rules_right(rules) - local nr = {} - for i, rule in ipairs(rules) do - table.insert(nr, { - x = -rule.z, - y = rule.y, - z = rule.x, - name = rule.name, - spread = rule.spread,}) - end - return nr -end -function mesecon.rotate_rules_left(rules) - local nr = {} - for i, rule in ipairs(rules) do - table.insert(nr, { - x = rule.z, - y = rule.y, - z = -rule.x, - name = rule.name, - spread = rule.spread,}) - end - return nr -end - -function mesecon.rotate_rules_down(rules) - local nr = {} - for i, rule in ipairs(rules) do - table.insert(nr, { - x = -rule.y, - y = rule.x, - z = rule.z, - name = rule.name, - spread = rule.spread,}) - end - return nr -end - -function mesecon.rotate_rules_up(rules) - local nr = {} - for i, rule in ipairs(rules) do - table.insert(nr, { - x = rule.y, - y = -rule.x, - z = rule.z, - name = rule.name, - spread = rule.spread,}) - end - return nr -end diff --git a/mods/ITEMS/REDSTONE/mesecons/presets.lua b/mods/ITEMS/REDSTONE/mesecons/presets.lua index 3d65cfe7..f624c52f 100644 --- a/mods/ITEMS/REDSTONE/mesecons/presets.lua +++ b/mods/ITEMS/REDSTONE/mesecons/presets.lua @@ -42,12 +42,22 @@ mesecon.rules.buttonlike = {x =-1, y = 0, z = 0}, {x = 1, y = 0, z = 0, spread = true}} +mesecon.rules.floor = +{{x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 0, y = 1, z = 0}, + {x = 0, y =-1, z = 0, spread = true}, + {x = 0, y = 0, z = 1}, + {x = 0, y = 0, z =-1}} + mesecon.rules.flat = {{x = 1, y = 0, z = 0}, {x =-1, y = 0, z = 0}, {x = 0, y = 0, z = 1}, {x = 0, y = 0, z =-1}} + + -- NOT IN ORIGNAL MESECONS mesecon.rules.mcl_alldirs_spread = {{x= 1, y= 0, z= 0, spread = true}, @@ -59,23 +69,41 @@ mesecon.rules.mcl_alldirs_spread = -- END OF UNOFFICIAL RULES +local rules_buttonlike = { + xp = mesecon.rules.buttonlike, + xn = mesecon.rotate_rules_right(mesecon.rotate_rules_right(mesecon.rules.buttonlike)), + yp = mesecon.rotate_rules_down(mesecon.rules.buttonlike), + yn = mesecon.rotate_rules_up(mesecon.rules.buttonlike), + zp = mesecon.rotate_rules_right(mesecon.rules.buttonlike), + zn = mesecon.rotate_rules_left(mesecon.rules.buttonlike), +} + +local rules_wallmounted = { + xp = mesecon.rotate_rules_down(mesecon.rules.floor), + xn = mesecon.rotate_rules_up(mesecon.rules.floor), + yp = mesecon.rotate_rules_up(mesecon.rotate_rules_up(mesecon.rules.floor)), + yn = mesecon.rules.floor, + zp = mesecon.rotate_rules_left(mesecon.rotate_rules_up(mesecon.rules.floor)), + zn = mesecon.rotate_rules_right(mesecon.rotate_rules_up(mesecon.rules.floor)), +} + +local function rules_from_dir(ruleset, dir) + if dir.x == 1 then return ruleset.xp end + if dir.y == 1 then return ruleset.yp end + if dir.z == 1 then return ruleset.zp end + if dir.x == -1 then return ruleset.xn end + if dir.y == -1 then return ruleset.yn end + if dir.z == -1 then return ruleset.zn end +end + mesecon.rules.buttonlike_get = function(node) - local rules = mesecon.rules.buttonlike local dir = minetest.facedir_to_dir(node.param2) - if dir.x == 1 then - -- No action needed - elseif dir.z == -1 then - rules=mesecon.rotate_rules_left(rules) - elseif dir.x == -1 then - rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) - elseif dir.z == 1 then - rules=mesecon.rotate_rules_right(rules) - elseif dir.y == -1 then - rules=mesecon.rotate_rules_up(rules) - elseif dir.y == 1 then - rules=mesecon.rotate_rules_down(rules) - end - return rules + return rules_from_dir(rules_buttonlike, dir) +end + +mesecon.rules.wallmounted_get = function(node) + local dir = minetest.wallmounted_to_dir(node.param2) + return rules_from_dir(rules_wallmounted, dir) end mesecon.state.on = "on" diff --git a/mods/ITEMS/REDSTONE/mesecons/util.lua b/mods/ITEMS/REDSTONE/mesecons/util.lua index fc7e1f2e..f6dac3f5 100644 --- a/mods/ITEMS/REDSTONE/mesecons/util.lua +++ b/mods/ITEMS/REDSTONE/mesecons/util.lua @@ -6,6 +6,59 @@ function mesecon.move_node(pos, newpos) minetest.get_meta(pos):from_table(meta) end +--Rules rotation Functions: +function mesecon.rotate_rules_right(rules) + local nr = {} + for i, rule in ipairs(rules) do + table.insert(nr, { + x = -rule.z, + y = rule.y, + z = rule.x, + name = rule.name, + spread = rule.spread,}) + end + return nr +end + +function mesecon.rotate_rules_left(rules) + local nr = {} + for i, rule in ipairs(rules) do + table.insert(nr, { + x = rule.z, + y = rule.y, + z = -rule.x, + name = rule.name, + spread = rule.spread,}) + end + return nr +end + +function mesecon.rotate_rules_down(rules) + local nr = {} + for i, rule in ipairs(rules) do + table.insert(nr, { + x = -rule.y, + y = rule.x, + z = rule.z, + name = rule.name, + spread = rule.spread,}) + end + return nr +end + +function mesecon.rotate_rules_up(rules) + local nr = {} + for i, rule in ipairs(rules) do + table.insert(nr, { + x = rule.y, + y = -rule.x, + z = rule.z, + name = rule.name, + spread = rule.spread,}) + end + return nr +end + function mesecon.flattenrules(allrules) --[[ { diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 5bd9bdcd..ff6f7f4b 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -2,7 +2,7 @@ -- A button that when pressed emits power for 1 second -- and then turns off again -local button_get_output_rules = mesecon.rules.buttonlike_get +local button_get_output_rules = mesecon.rules.wallmounted_get local boxes_off = { type = "wallmounted", diff --git a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua index 579f1c1d..35e339d3 100644 --- a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua @@ -16,7 +16,9 @@ local rotate_torch_rules = function (rules, param2) end end -local torch_get_output_rules = mesecon.rules.alldirs +local torch_get_output_rules = function() + return mesecon.rules.mcl_alldirs_spread +end local torch_get_input_rules = function(node) local rules = {{x = -2, y = 0, z = 0}, From 483d6d088c6ade360d2abac6af990826d70e4396 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 04:45:04 +0100 Subject: [PATCH 06/27] Make redstone wire transmit power vertically, too --- mods/ITEMS/REDSTONE/mesecons_wires/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index 52450342..da00fdf7 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -163,7 +163,10 @@ local function register_wires() nodebox.fixed = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16} end - local rules = {} + local rules = { + {x=0, y=-1, z=0, spread=true}, + {x=0, y= 1, z=0, spread=true}, + } if (nid[0] == 1) then table.insert(rules, {x=1, y= 0,z= 0, spread=true}) end if (nid[1] == 1) then table.insert(rules, {x=0, y= 0,z= 1, spread=true}) end if (nid[2] == 1) then table.insert(rules, {x=-1,y= 0,z= 0, spread=true}) end From 81d5d8b942814320466179078b103168ce528cd7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 13 Jan 2018 05:00:47 +0100 Subject: [PATCH 07/27] Update comparator help --- mods/ITEMS/REDSTONE/mcl_comparators/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index 49ea52e6..8b87fd76 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -211,11 +211,11 @@ for _, state in pairs{mesecon.state.on, mesecon.state.off} do local longdesc, usagehelp, use_help if state_strs[state] == "off" and mode == "comp" then longdesc = "Redstone comparators are redstone components which ".. - "compare redstone signals and measure various node states, such as ".. - "how full inventories are." + "compare redstone signals and measure various block states, such as ".. + "how full inventories are. NOTE: This item is incomplete." usagehelp = "To power a redstone comparater, send a signal in “arrow” ".. - "direction, or place the block to measure there. Send the signal ".. + "direction, or place the block to measure there. Send the signal ".. "to compare with in from the side." else use_help = false From d61da938f4720ccdfe860d6c131800f9b9eca83c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 16 Jan 2018 20:58:54 +0100 Subject: [PATCH 08/27] Fix /seed giving wrong seed --- mods/MISC/mcl_commands/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index 90ec60b7..24373e37 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -141,7 +141,7 @@ minetest.register_chatcommand("seed", { params = "", privs = {}, func = function(name) - minetest.chat_send_player(name, string.format("%d", minetest.get_mapgen_setting("seed"))) + minetest.chat_send_player(name, minetest.get_mapgen_setting("seed")) end }) From 2d5b51983000384db7228b1871913300b7e865c0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 01:45:12 +0100 Subject: [PATCH 09/27] Fix weird fence mesecon behaviour --- mods/ITEMS/mcl_fences/init.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index 57c10f2b..023817fd 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -161,9 +161,6 @@ mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, action_off = (function(pos, node) punch_gate(pos, node) end), - action_on = (function(pos, node) - punch_gate(pos, node) - end), }}, on_rotate = on_rotate, sounds = sounds, From 1522c875ae24fca99eadfce1e3813c323d93ceac Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 02:44:00 +0100 Subject: [PATCH 10/27] Code opaque block redstone power rule (part 1) --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 51 ++++++++++++++--------- mods/ITEMS/REDSTONE/mesecons/services.lua | 33 ++++++++++++++- mods/ITEMS/REDSTONE/mesecons/util.lua | 9 +--- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index ffde3b66..89c8426b 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -37,7 +37,7 @@ -- HIGH-LEVEL Internals -- mesecon.is_power_on(pos) --> Returns true if pos emits power in any way -- mesecon.is_power_off(pos) --> Returns true if pos does not emit power in any way --- mesecon.is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor +-- mesecon.is_powered(pos) --> Returns true if pos is powered by a receptor, a conductor or an opaque block -- RULES ROTATION helpers -- mesecon.rotate_rules_right(rules) @@ -78,6 +78,8 @@ function mesecon.get_any_outputrules(node) return mesecon.conductor_get_rules(node) elseif mesecon.is_receptor(node.name) then return mesecon.receptor_get_rules(node) + elseif minetest.get_item_group(node.name, "opaque") == 1 then + return mesecon.rules.alldirs end end @@ -88,6 +90,8 @@ function mesecon.get_any_inputrules(node) return mesecon.conductor_get_rules(node) elseif mesecon.is_effector(node.name) then return mesecon.effector_get_rules(node) + elseif minetest.get_item_group(node.name, "opaque") == 1 then + return mesecon.rules.alldirs end end @@ -512,37 +516,45 @@ function mesecon.rules_link_rule_all_inverted(input, rule) return rules end -function mesecon.is_powered(pos, rule) +function mesecon.is_powered(pos, rule, depth, sourcepos) + if depth == nil then depth = 0 end + if depth > 1 then + return false + end local node = mesecon.get_node_force(pos) local rules = mesecon.get_any_inputrules(node) - if not rules then return false end + if not rules then + return false + end -- List of nodes that send out power to pos - local sourcepos = {} + if sourcepos == nil then + sourcepos = {} + end - if not rule then - for _, rule in ipairs(mesecon.flattenrules(rules)) do - local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - for _, rname in ipairs(rulenames) do - local np = vector.add(pos, rname) - local nn = mesecon.get_node_force(np) - - if (mesecon.is_conductor_on(nn, mesecon.invertRule(rname)) - or mesecon.is_receptor_on(nn.name)) then - table.insert(sourcepos, np) - end - end - end - else - local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) + local function power_walk(pos, sourcepos, rulenames, rule, depth) for _, rname in ipairs(rulenames) do local np = vector.add(pos, rname) local nn = mesecon.get_node_force(np) if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname)) or mesecon.is_receptor_on (nn.name)) then table.insert(sourcepos, np) + elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then + local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos) + mesecon.mergetable(sourcepos, more_sourcepos) end end + return sourcepos + end + + if not rule then + for _, rule in ipairs(mesecon.flattenrules(rules)) do + local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) + sourcepos = power_walk(pos, sourcepos, rulenames, rule, depth) + end + else + local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) + sourcepos = power_walk(pos, sourcepos, rulenames, rule, depth) end -- Return FALSE if not powered, return list of sources if is powered @@ -550,4 +562,3 @@ function mesecon.is_powered(pos, rule) else return sourcepos end end - diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index 1e12de08..087ec82d 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -50,6 +50,23 @@ mesecon.on_placenode = function(pos, node) end end end + + if minetest.get_item_group(node.name, "opaque") == 1 then + local neighbors = mesecon.mcl_get_neighbors(pos) + local is_powered = mesecon.is_powered(pos) + if is_powered then + for n=1, #neighbors do + local npos = neighbors[n].pos + local nnode = minetest.get_node(npos) + if mesecon.is_conductor_off(nnode) then + mesecon.receptor_on(npos, mesecon.conductor_get_rules(nnode)) + elseif mesecon.is_effector_off(nnode.name) then + mesecon.changesignal(npos, nnode, neighbors[n].link, mesecon.state.on, 1) + mesecon.activate(npos, nnode, neighbors[n].link, 1) + end + end + end + end end mesecon.on_dignode = function(pos, node) @@ -58,7 +75,21 @@ mesecon.on_dignode = function(pos, node) elseif mesecon.is_receptor_on(node.name) then mesecon.receptor_off(pos, mesecon.receptor_get_rules(node)) end - + if minetest.get_item_group(node.name, "opaque") == 1 then + local sources = mesecon.is_powered(pos) + local neighbors = mesecon.mcl_get_neighbors(pos) + for n=1, #neighbors do + local npos = neighbors[n].pos + local nlink = neighbors[n].link + local nnode = minetest.get_node(npos) + if mesecon.is_conductor_on(nnode) and not mesecon.is_powered(npos) then + mesecon.receptor_off(npos, mesecon.conductor_get_rules(nnode)) + elseif mesecon.is_effector_on(nnode.name) and not mesecon.is_powered(npos) then + mesecon.changesignal(npos, nnode, nlink, mesecon.state.off, 1) + mesecon.deactivate(npos, nnode, nlink, 1) + end + end + end mesecon.execute_autoconnect_hooks_queue(pos, node) end diff --git a/mods/ITEMS/REDSTONE/mesecons/util.lua b/mods/ITEMS/REDSTONE/mesecons/util.lua index f6dac3f5..c848b9d3 100644 --- a/mods/ITEMS/REDSTONE/mesecons/util.lua +++ b/mods/ITEMS/REDSTONE/mesecons/util.lua @@ -147,14 +147,7 @@ end -- (nodes which touch the sides of pos). -- NOT PART OF ORIGINAL MESECONS! function mesecon.mcl_get_neighbors(pos) - local r = { - { x= 0, y= 0, z=-1 }, - { x= 0, y= 0, z= 1 }, - { x= 0, y=-1, z= 0 }, - { x= 0, y= 1, z= 0 }, - { x=-1, y= 0, z= 0 }, - { x= 1, y= 0, z= 0 }, - } + local r = mesecon.rules.alldirs local e = {} for i=1, #r do table.insert(e, { pos = vector.add(pos, r[i]), link = r[i] }) From 2cf6332b57452b762d3d34b33c4d0b6914388b00 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 03:05:12 +0100 Subject: [PATCH 11/27] Conductors no longer power themselves --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 89c8426b..dae3c171 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -516,7 +516,7 @@ function mesecon.rules_link_rule_all_inverted(input, rule) return rules end -function mesecon.is_powered(pos, rule, depth, sourcepos) +function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if depth == nil then depth = 0 end if depth > 1 then return false @@ -526,6 +526,9 @@ function mesecon.is_powered(pos, rule, depth, sourcepos) if not rules then return false end + if not home_pos then + home_pos = pos + end -- List of nodes that send out power to pos if sourcepos == nil then @@ -538,9 +541,11 @@ function mesecon.is_powered(pos, rule, depth, sourcepos) local nn = mesecon.get_node_force(np) if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname)) or mesecon.is_receptor_on (nn.name)) then - table.insert(sourcepos, np) + if not vector.equals(home_pos, np) then + table.insert(sourcepos, np) + end elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then - local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos) + local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos) mesecon.mergetable(sourcepos, more_sourcepos) end end From af3db1ae2186f6ac51d05b4b77037543ba540d2b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 03:54:51 +0100 Subject: [PATCH 12/27] Fix opaque block placement propagate power too far --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 25 ++++++++++++++++------- mods/ITEMS/REDSTONE/mesecons/services.lua | 4 ++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index dae3c171..0e5667e7 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -37,7 +37,9 @@ -- HIGH-LEVEL Internals -- mesecon.is_power_on(pos) --> Returns true if pos emits power in any way -- mesecon.is_power_off(pos) --> Returns true if pos does not emit power in any way --- mesecon.is_powered(pos) --> Returns true if pos is powered by a receptor, a conductor or an opaque block +-- mesecon.is_powered(pos) --> Returns bool, direct_source. bool is true if pos is powered by a receptor, a conductor or an opaque block. + -- direct_source is true if it powered at least by one power source directly + -- (rather than just indirectly with a strongly-powered (opaque) block. -- RULES ROTATION helpers -- mesecon.rotate_rules_right(rules) @@ -536,6 +538,7 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) end local function power_walk(pos, sourcepos, rulenames, rule, depth) + local direct_source = false for _, rname in ipairs(rulenames) do local np = vector.add(pos, rname) local nn = mesecon.get_node_force(np) @@ -543,27 +546,35 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) or mesecon.is_receptor_on (nn.name)) then if not vector.equals(home_pos, np) then table.insert(sourcepos, np) + direct_source = true end elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos) - mesecon.mergetable(sourcepos, more_sourcepos) + if more_sourcepos and #more_sourcepos > 0 then + mesecon.mergetable(sourcepos, more_sourcepos) + end end end - return sourcepos + return sourcepos, direct_source end + local direct_source if not rule then for _, rule in ipairs(mesecon.flattenrules(rules)) do local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos = power_walk(pos, sourcepos, rulenames, rule, depth) + sourcepos, direct_source = power_walk(pos, sourcepos, rulenames, rule, depth) end else local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos = power_walk(pos, sourcepos, rulenames, rule, depth) + sourcepos, direct_source = power_walk(pos, sourcepos, rulenames, rule, depth) end -- Return FALSE if not powered, return list of sources if is powered - if (#sourcepos == 0) then return false - else return sourcepos end + + if (#sourcepos == 0) then + return false + else + return sourcepos, direct_source + end end diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index 087ec82d..43d94cc0 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -53,8 +53,8 @@ mesecon.on_placenode = function(pos, node) if minetest.get_item_group(node.name, "opaque") == 1 then local neighbors = mesecon.mcl_get_neighbors(pos) - local is_powered = mesecon.is_powered(pos) - if is_powered then + local is_powered, direct_source = mesecon.is_powered(pos) + if is_powered and direct_source then for n=1, #neighbors do local npos = neighbors[n].pos local nnode = minetest.get_node(npos) From f009e958f51eafa2c4fc7397b237bee9721575c7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 05:49:11 +0100 Subject: [PATCH 13/27] Redstone: Fix internal logic a bit --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 0e5667e7..7ba3303d 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -537,7 +537,7 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) sourcepos = {} end - local function power_walk(pos, sourcepos, rulenames, rule, depth) + local function power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) local direct_source = false for _, rname in ipairs(rulenames) do local np = vector.add(pos, rname) @@ -562,11 +562,11 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if not rule then for _, rule in ipairs(mesecon.flattenrules(rules)) do local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos, direct_source = power_walk(pos, sourcepos, rulenames, rule, depth) + sourcepos, direct_source = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) end else local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos, direct_source = power_walk(pos, sourcepos, rulenames, rule, depth) + sourcepos, direct_source = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) end -- Return FALSE if not powered, return list of sources if is powered From dba463ca6d362afbf64904b87dad2ee609e19da9 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 17:15:08 +0100 Subject: [PATCH 14/27] Fix broken direct_source in mesecon.is_powered --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 7ba3303d..de8d9b5a 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -521,12 +521,12 @@ end function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if depth == nil then depth = 0 end if depth > 1 then - return false + return false, false end local node = mesecon.get_node_force(pos) local rules = mesecon.get_any_inputrules(node) if not rules then - return false + return false, false end if not home_pos then home_pos = pos @@ -558,11 +558,15 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) return sourcepos, direct_source end - local direct_source + local direct_source = false if not rule then for _, rule in ipairs(mesecon.flattenrules(rules)) do + local direct_source_temp local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos, direct_source = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) + sourcepos, direct_source_temp = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) + if direct_source_temp then + direct_source = true + end end else local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) @@ -572,7 +576,7 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) -- Return FALSE if not powered, return list of sources if is powered if (#sourcepos == 0) then - return false + return false, false else return sourcepos, direct_source end From ec49459eb490ee96b65444570eb8ec73bffe6993 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 19:30:43 +0100 Subject: [PATCH 15/27] Update desert temple schematic --- mods/MAPGEN/mcl_structures/init.lua | 15 ++++++++++++--- .../mcl_structures_desert_temple.mts | Bin 1360 -> 1354 bytes 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index cabfc5d3..25f51e09 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -236,9 +236,10 @@ mcl_structures.generate_desert_temple = function(pos) local chests = minetest.find_nodes_in_area({x=newpos.x-size.x, y=newpos.y, z=newpos.z-size.z}, vector.add(newpos, size), "mcl_chests:chest") -- Add desert temple loot into chests + -- FIXME: Use better seeding + local pr = PseudoRandom(math.random(0, 4294967295)) for c=1, #chests do -- FIXME: Use better seeding - local pr = PseudoRandom(math.random(0, 4294967295)) local lootitems = mcl_loot.get_multi_loot({ { stacks_min = 2, @@ -283,10 +284,18 @@ mcl_structures.generate_desert_temple = function(pos) end end - -- Initialize pressure plates + -- Initialize pressure plates and randomly remove up to 5 plates local pplates = minetest.find_nodes_in_area({x=newpos.x-size.x, y=newpos.y, z=newpos.z-size.z}, vector.add(newpos, size), "mesecons_pressureplates:pressure_plate_stone_off") + local pplates_remove = 5 for p=1, #pplates do - minetest.registered_nodes["mesecons_pressureplates:pressure_plate_stone_off"].on_construct(pplates[p]) + if pplates_remove > 0 and pr:next(1, 100) >= 50 then + -- Remove plate + minetest.remove_node(pplates[p]) + pplates_remove = pplates_remove - 1 + else + -- Initialize plate + minetest.registered_nodes["mesecons_pressureplates:pressure_plate_stone_off"].on_construct(pplates[p]) + end end return ret diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_desert_temple.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_desert_temple.mts index 62b9db6a9b00ffa330c70713d37d570c5725acbe..b60bce2dd07383e7979453f37e74abaae1b37374 100644 GIT binary patch delta 1000 zcmV@ewCN2S!Yyl>Jor{{IAPh!nZD+fecb-?@TBlVpU_elibMp1; zZYGNu;y;L&H3q8WlF6MG)D*?)Ov4b}x_NJwq;cJnRwP?LUXvY`IWIuhdtJhaQa%?yA zX=CN1X8LcLKj{^hf7{9*JJ#3sNJwp_J>F`I?Tz&ZkjSAA zmybU9D`pzwkG5ATe9;3TwJBGB@?3BH`|{Q&jSXvzsgJ+X4eA7aSn7kkeSh6w9j$5l z*MdQvY}JRGqs?~oK^wX3Ns8mH7Aup^JZ9&leoEbooVYY#i#`}ZA3E#X7<>IeA3Kef zV$Cdedd4vS9{ux5ma6-`75mH}R3EgFu6?Q1w(-h%=}Yu3vEdVh@8l*{Tn&HrvsMcN=nR zn*Oz5P$%faQXdAme=?;(o#fC5p1-Iowl|)?0ExW%;H#0hZ~pCzm7m|Vv15HzI(T`0 zQyO?s0Y#c^Mjm!W9}m&b*H4DdJvs^5tz2ql6C%IH)-cy91?M)a+QI-@#e{+4^lmh zgKBNaa*HD+4q&okkoKTa_NxbnJ|wOOxk%Q%`iz|$^ue(Qjl%q4(bcBm{KD!};}ld6 ztUnY0>yw{N!#CG2X6*piH>d3Y_dgiJ{SOmd^)OBBCU53fF_yjPLo9oZ(7xXA`2zp| z0Bk}3D5LmdW&Qv5l#%{XJfS0(GI|H4z+=0u!pH*vK@hxCN2RP7Hwl}UvzJBV`yb_I&^PxV`yJ@VQg#wB9Uqye`0KP zWq6$JoPnC6AQVPPt!-y_pLt(>A~FpxaxpL%&$*wqOIJqZ=MObC2AbrQ6#DhLS#B2% zV|p{(mi)PcIp3Dg);ruoyA8d18}$3v#zmP|CZJ8W`a`T%s|cMcta|#}@+XPRKvJOM@2Wd^_53kvpOdHG}z){j4#v_dW zp?qmEPxZK0`^_vbOTSsKQ>V&pky}hCgR_OX7;|Gf9sEWO{Vsk zMb@(Oo3+d-MsL!DI|rF}{M8=NCiuhp`fFvcf1z8gbGb&ovDZRCo4oH2gIKH6#4-Fq zo4MSc_s3l;Q7gT<&gO{gjK{f0BJ2U3a`q7N2UmxCwb6U;qi#B7?(+OYD0done$V&b z`+S5>bN;gapv{!p+HUO0fA4!}=*`z{+rCr|Flf?mua(K4aQ!0QZfJ$~{XwqPY2q0E zFxIqI=W>mFW3PpPHo+glTITnY`2yOcggbEmMQyn@xc>suDd`WBGS-x0%X(FAr_LSA zxPS9CTa#&n`!~T+f7Ty({zD!9!1Etq8)f}L!#FN@eiZWusEw`u5X($Gmgf1B<2La8 zNvMZ3f6&J#wMbMK|KW~tuRe{H?zFQGfVeAPcd)$MRi*Fs{9{26JEG9Tvk*P}e1u(T zBs~~k507H>@Uz(L56?nDJDK#LFHLSX1jyF)exd)#vIiGke;q1~v$^@;@ew_Uh3KIM zYSM#Ph#q#O;QS$%9>hZQP=;c9FkUrNVJ1Dy3zdz9C_DQDdZ--y0p>7&fH@prz?_=& z!1;&I!}&>=qrINBQ6zH5yY&?(Dl4riXIxHY`>w0 z*6{aio3I}MOaOKu?OwIOJ=6MIsf%F$yztcTQ^KRb;Q(-7=24;N0RW&i`0fG#8GDHP k;lu9`9DM@-0000006>HA`v+(jt|S~4dLA Date: Wed, 17 Jan 2018 20:20:08 +0100 Subject: [PATCH 16/27] Redstone: Make is_powered respect spread --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index de8d9b5a..9461b72a 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -545,8 +545,21 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname)) or mesecon.is_receptor_on (nn.name)) then if not vector.equals(home_pos, np) then - table.insert(sourcepos, np) - direct_source = true + local rulez = mesecon.get_any_outputrules(nn) + local ds_tmp = false + for r=1, #rulez do + if vector.equals(mesecon.invertRule(rname), rulez[r]) then + if rulez[r].spread then + ds_tmp = true + end + end + end + if depth == 0 or ds_tmp then + table.insert(sourcepos, np) + if ds_tmp then + direct_source = true + end + end end elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos) From 5d913b6d293bac91a51e82497702cb69a917946a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 20:23:43 +0100 Subject: [PATCH 17/27] Refactor some redstone internal code --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 9461b72a..3a75a23f 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -37,9 +37,8 @@ -- HIGH-LEVEL Internals -- mesecon.is_power_on(pos) --> Returns true if pos emits power in any way -- mesecon.is_power_off(pos) --> Returns true if pos does not emit power in any way --- mesecon.is_powered(pos) --> Returns bool, direct_source. bool is true if pos is powered by a receptor, a conductor or an opaque block. - -- direct_source is true if it powered at least by one power source directly - -- (rather than just indirectly with a strongly-powered (opaque) block. +-- mesecon.is_powered(pos) --> Returns bool, spread. bool is true if pos is powered by a receptor, a conductor or an opaque block. + -- spread is true if it is powered AND also transmits its power one block further. -- RULES ROTATION helpers -- mesecon.rotate_rules_right(rules) @@ -538,7 +537,7 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) end local function power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) - local direct_source = false + local spread = false for _, rname in ipairs(rulenames) do local np = vector.add(pos, rname) local nn = mesecon.get_node_force(np) @@ -546,18 +545,18 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) or mesecon.is_receptor_on (nn.name)) then if not vector.equals(home_pos, np) then local rulez = mesecon.get_any_outputrules(nn) - local ds_tmp = false + local spread_tmp = false for r=1, #rulez do if vector.equals(mesecon.invertRule(rname), rulez[r]) then if rulez[r].spread then - ds_tmp = true + spread_tmp = true end end end - if depth == 0 or ds_tmp then + if depth == 0 or spread_tmp then table.insert(sourcepos, np) - if ds_tmp then - direct_source = true + if spread_tmp then + spread = true end end end @@ -568,22 +567,22 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) end end end - return sourcepos, direct_source + return sourcepos, spread end - local direct_source = false + local spread = false if not rule then for _, rule in ipairs(mesecon.flattenrules(rules)) do - local direct_source_temp + local spread_temp local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos, direct_source_temp = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) - if direct_source_temp then - direct_source = true + sourcepos, spread_temp = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) + if spread_temp then + spread = true end end else local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule) - sourcepos, direct_source = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) + sourcepos, spread = power_walk(pos, home_pos, sourcepos, rulenames, rule, depth) end -- Return FALSE if not powered, return list of sources if is powered @@ -591,7 +590,7 @@ function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos) if (#sourcepos == 0) then return false, false else - return sourcepos, direct_source + return sourcepos, spread end end From c9ef3f8536bc344a09ddffabe6dd4752e476acfe Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 21:01:26 +0100 Subject: [PATCH 18/27] Use default redstone rules for rails again --- mods/ENTITIES/mcl_minecarts/rails.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index 570440ef..a5be21c7 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -55,7 +55,7 @@ register_rail("mcl_minecarts:golden_rail", state = mesecon.state.off, offstate = "mcl_minecarts:golden_rail", onstate = "mcl_minecarts:golden_rail_on", - rules = mesecon.rules.alldirs, + rules = mesecon.rules.default, }, }, } @@ -72,7 +72,7 @@ register_rail("mcl_minecarts:golden_rail_on", state = mesecon.state.on, offstate = "mcl_minecarts:golden_rail", onstate = "mcl_minecarts:golden_rail_on", - rules = mesecon.rules.alldirs, + rules = mesecon.rules.default, }, }, drop = "mcl_minecarts:golden_rail", @@ -93,7 +93,7 @@ register_rail("mcl_minecarts:activator_rail", state = mesecon.state.off, offstate = "mcl_minecarts:activator_rail", onstate = "mcl_minecarts:activator_rail_on", - rules = mesecon.rules.alldirs, + rules = mesecon.rules.default, }, }, } @@ -109,7 +109,7 @@ register_rail("mcl_minecarts:activator_rail_on", state = mesecon.state.on, offstate = "mcl_minecarts:activator_rail", onstate = "mcl_minecarts:activator_rail_on", - rules = mesecon.rules.alldirs, + rules = mesecon.rules.default, }, }, drop = "mcl_minecarts:activator_rail", From b04e5556356e68449801a1aa008029f59f6da67e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 22:30:27 +0100 Subject: [PATCH 19/27] Update help text of comparators --- mods/ITEMS/REDSTONE/mcl_comparators/init.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index 8b87fd76..c36c2f18 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -210,13 +210,19 @@ for _, state in pairs{mesecon.state.on, mesecon.state.off} do -- Help local longdesc, usagehelp, use_help if state_strs[state] == "off" and mode == "comp" then - longdesc = "Redstone comparators are redstone components which ".. - "compare redstone signals and measure various block states, such as ".. - "how full inventories are. NOTE: This item is incomplete." + longdesc = "Redstone comparators are multi-purpose redstone components. ".. + "They can transmit a redstone signal, detect whether a block contains any items and compare multiple signals." - usagehelp = "To power a redstone comparater, send a signal in “arrow” ".. - "direction, or place the block to measure there. Send the signal ".. - "to compare with in from the side." + usagehelp = "A redstone comparator has 1 main input, 2 side inputs and 1 output. The output is in ".. + "arrow direction, the main input is in the opposite direction. The other 2 sides are the side inputs.".."\n".. + "The main input can powered in 2 ways: First, it can be powered directly by redstone power like any other component. Second, it is powered if, and only if a container (like chest) is placed in front of it and the container contains at least one item.".. + "The side inputs are only powered by normal redstone power.".. + "The redstone can operate in two modes: Transmission mode and subtraction mode. It ".. + "starts in transmission mode and the mode can be changed by a rightclick.".."\n\n".. + "Transmission mode:".. + "The front torch is unlit and lowered. The output is powered if, and only if the main input is powered. The two side inputs are ignored.".."\n".. + "Subtraction mode:".. + "The front torch is lit. The output is powered if, and only if the main input is powered and none of the side inputs is powered." else use_help = false end From 92aa0114a2ef430d727c2378b9aa98ff4a2774aa Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 17 Jan 2018 22:36:48 +0100 Subject: [PATCH 20/27] Fix redstone having 2 help entries --- mods/ITEMS/REDSTONE/mesecons_wires/init.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index da00fdf7..bf6b19b1 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -225,7 +225,7 @@ local function register_wires() tiles_off = { dot_off, dot_off, "blank.png", "blank.png", "blank.png", "blank.png" } tiles_on = { dot_on, dot_on, "blank.png", "blank.png", "blank.png", "blank.png" } - longdesc = [[Redstone is a versatile conductive mineral which transmits redstone power. It can be placed on trail the ground as a trail. + longdesc = [[Redstone is a versatile conductive mineral which transmits redstone power. It can be placed on the ground as a trail. A redstone trail can be in two states: Powered or not powered. A powered redstone trail will power (and thus activate) adjacent redstone components. Redstone power can be received from various redstone components, such as a block of redstone or a button. Redstone power is used to activate numerous mechanisms, such as redstone lamps or pistons.]] usagehelp = [[Place redstone on the ground to build a redstone trail. The trails will connect to each other automatically and it can also go over hills. An easy way to power a redstone trail is by placing a redstone torch. @@ -241,9 +241,6 @@ Read the help entries on the other redstone components to learn how redstone com mesecon.register_node(":mesecons:wire_"..nodeid, { description = "Redstone", - _doc_items_create_entry = wirehelp, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, drawtype = "nodebox", inventory_image = "redstone_redstone_dust.png", wield_image = "redstone_redstone_dust.png", @@ -255,8 +252,19 @@ Read the help entries on the other redstone components to learn how redstone com drop = "mesecons:wire_00000000_off", sounds = mcl_sounds.node_sound_defaults(), mesecon_wire = true - }, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off}, - {tiles = tiles_on, mesecons = meseconspec_on, groups = groups_on}) + },{ + _doc_items_create_entry = wirehelp, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + tiles = tiles_off, + mesecons = meseconspec_off, + groups = groups_off, + },{ + _doc_items_create_entry = false, + tiles = tiles_on, + mesecons = meseconspec_on, + groups = groups_on + }) -- Add Help entry aliases for e.g. making it identifiable by the lookup tool [doc_identifier] if minetest.get_modpath("doc") then From aec2fb8309d57bde9c795ce78859615d68c2f47a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 18 Jan 2018 19:22:52 +0100 Subject: [PATCH 21/27] Remove legacy mesecons code --- mods/ITEMS/REDSTONE/mesecons/init.lua | 4 ---- mods/ITEMS/REDSTONE/mesecons/legacy.lua | 14 -------------- 2 files changed, 18 deletions(-) delete mode 100644 mods/ITEMS/REDSTONE/mesecons/legacy.lua diff --git a/mods/ITEMS/REDSTONE/mesecons/init.lua b/mods/ITEMS/REDSTONE/mesecons/init.lua index 57b17b5b..4ef690b8 100644 --- a/mods/ITEMS/REDSTONE/mesecons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons/init.lua @@ -140,9 +140,5 @@ end print("[OK] Mesecons") --- Deprecated stuff --- To be removed in future releases -dofile(minetest.get_modpath("mesecons").."/legacy.lua"); - --Services like turnoff receptor on dignode and so on dofile(minetest.get_modpath("mesecons").."/services.lua"); diff --git a/mods/ITEMS/REDSTONE/mesecons/legacy.lua b/mods/ITEMS/REDSTONE/mesecons/legacy.lua deleted file mode 100644 index ad7093a0..00000000 --- a/mods/ITEMS/REDSTONE/mesecons/legacy.lua +++ /dev/null @@ -1,14 +0,0 @@ --- Un-forceload any forceloaded mapblocks from older versions of Mesecons which --- used forceloading instead of VoxelManipulators. -local BLOCKSIZE = 16 - --- convert block hash --> node position -local function unhash_blockpos(hash) - return vector.multiply(minetest.get_position_from_hash(hash), BLOCKSIZE) -end - -local old_forceloaded_blocks = mesecon.file2table("mesecon_forceloaded") -for hash, _ in pairs(old_forceloaded_blocks) do - minetest.forceload_free_block(unhash_blockpos(hash)) -end -os.remove(minetest.get_worldpath()..DIR_DELIM.."mesecon_forceloaded") From d5a72d240fb777ea7b3456cb18f6590b7281cca1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 18 Jan 2018 20:00:41 +0100 Subject: [PATCH 22/27] Tweak redstone wire rules --- mods/ITEMS/REDSTONE/mesecons_wires/init.lua | 47 ++++++++++----------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index bf6b19b1..f9eacae3 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -8,6 +8,23 @@ -- ## Update wire looks ## -- ####################### +local wire_rules = +{{x=-1, y= 0, z= 0, spread=true}, + {x= 1, y= 0, z= 0, spread=true}, + {x= 0, y=-1, z= 0, spread=true}, + {x= 0, y= 1, z= 0, spread=true}, + {x= 0, y= 0, z=-1, spread=true}, + {x= 0, y= 0, z= 1, spread=true}, + + {x= 1, y= 1, z= 0}, + {x= 1, y=-1, z= 0}, + {x=-1, y= 1, z= 0}, + {x=-1, y=-1, z= 0}, + {x= 0, y= 1, z= 1}, + {x= 0, y=-1, z= 1}, + {x= 0, y= 1, z=-1}, + {x= 0, y=-1, z=-1}} + -- self_pos = pos of any mesecon node, from_pos = pos of conductor to getconnect for local wire_getconnect = function (from_pos, self_pos) local node = minetest.get_node(self_pos) @@ -16,7 +33,7 @@ local wire_getconnect = function (from_pos, self_pos) -- rules of node to possibly connect to local rules = {} if (minetest.registered_nodes[node.name].mesecon_wire) then - rules = mesecon.rules.default + rules = wire_rules else rules = mesecon.get_any_rules(node) end @@ -34,7 +51,7 @@ end local wire_updateconnect = function (pos) local connections = {} - for _, r in ipairs(mesecon.rules.default) do + for _, r in ipairs(wire_rules) do if wire_getconnect(pos, vector.add(pos, r)) then table.insert(connections, r) end @@ -73,10 +90,9 @@ local update_on_place_dig = function (pos, node) end -- Update nodes around it - local rules = {} if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].mesecon_wire then - rules = mesecon.rules.default + rules = wire_rules else rules = mesecon.get_any_rules(node) end @@ -163,33 +179,14 @@ local function register_wires() nodebox.fixed = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16} end - local rules = { - {x=0, y=-1, z=0, spread=true}, - {x=0, y= 1, z=0, spread=true}, - } - if (nid[0] == 1) then table.insert(rules, {x=1, y= 0,z= 0, spread=true}) end - if (nid[1] == 1) then table.insert(rules, {x=0, y= 0,z= 1, spread=true}) end - if (nid[2] == 1) then table.insert(rules, {x=-1,y= 0,z= 0, spread=true}) end - if (nid[3] == 1) then table.insert(rules, {x= 0,y= 0,z=-1, spread=true}) end - - if (nid[0] == 1) then table.insert(rules, {x= 1,y=-1,z= 0}) end - if (nid[1] == 1) then table.insert(rules, {x= 0,y=-1,z= 1}) end - if (nid[2] == 1) then table.insert(rules, {x=-1,y=-1,z= 0}) end - if (nid[3] == 1) then table.insert(rules, {x= 0,y=-1,z= -1}) end - - if (nid[4] == 1) then table.insert(rules, {x= 1,y= 1,z= 0}) end - if (nid[5] == 1) then table.insert(rules, {x= 0,y= 1,z= 1}) end - if (nid[6] == 1) then table.insert(rules, {x=-1,y= 1,z= 0}) end - if (nid[7] == 1) then table.insert(rules, {x= 0,y= 1,z= -1}) end - local meseconspec_off = { conductor = { - rules = rules, + rules = wire_rules, state = mesecon.state.off, onstate = "mesecons:wire_"..nodeid.."_on" }} local meseconspec_on = { conductor = { - rules = rules, + rules = wire_rules, state = mesecon.state.on, offstate = "mesecons:wire_"..nodeid.."_off" }} From aaf68793fecfcfbc387bb0f5fcb8cdac44fa9609 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 19 Jan 2018 03:34:30 +0100 Subject: [PATCH 23/27] More redstone rule consistency --- mods/ITEMS/REDSTONE/mesecons/services.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index 43d94cc0..f7be0a5b 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -19,7 +19,7 @@ mesecon.on_placenode = function(pos, node) local rule = vector.subtract(pos, s) mesecon.turnon(pos, rule) end - --mesecon.receptor_on (pos, mesecon.conductor_get_rules(node)) + mesecon.receptor_on (pos, mesecon.conductor_get_rules(node)) elseif mesecon.is_conductor_on(node) then minetest.swap_node(pos, {name = mesecon.get_conductor_off(node)}) end @@ -82,9 +82,9 @@ mesecon.on_dignode = function(pos, node) local npos = neighbors[n].pos local nlink = neighbors[n].link local nnode = minetest.get_node(npos) - if mesecon.is_conductor_on(nnode) and not mesecon.is_powered(npos) then + if mesecon.is_conductor_on(nnode) then mesecon.receptor_off(npos, mesecon.conductor_get_rules(nnode)) - elseif mesecon.is_effector_on(nnode.name) and not mesecon.is_powered(npos) then + elseif mesecon.is_effector_on(nnode.name) then mesecon.changesignal(npos, nnode, nlink, mesecon.state.off, 1) mesecon.deactivate(npos, nnode, nlink, 1) end From 33d978de06b9f98da26e72dafe7a8708850f0fb4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 20 Jan 2018 19:04:53 +0100 Subject: [PATCH 24/27] Propagate redstone power through opaque blocks --- mods/ITEMS/REDSTONE/mesecons/init.lua | 20 --------------- mods/ITEMS/REDSTONE/mesecons/internal.lua | 31 +++++++++++++++++++---- mods/ITEMS/REDSTONE/mesecons/util.lua | 7 ++++- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/init.lua b/mods/ITEMS/REDSTONE/mesecons/init.lua index 4ef690b8..3286c0ce 100644 --- a/mods/ITEMS/REDSTONE/mesecons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons/init.lua @@ -81,13 +81,6 @@ mesecon.queue:add_function("receptor_on", function (pos, rules) for _, rulename in ipairs(rulenames) do mesecon.turnon(np, rulename) end - if rule.spread then - if minetest.get_item_group(minetest.get_node(np).name, "opaque") == 1 then - for _, neighbor in ipairs(mesecon.mcl_get_neighbors(np)) do - mesecon.turnon(neighbor.pos, vector.add(rule, neighbor.link)) - end - end - end end mesecon.vm_commit() @@ -117,19 +110,6 @@ mesecon.queue:add_function("receptor_off", function (pos, rules) mesecon.vm_abort() end end - if rule.spread then - if minetest.get_item_group(minetest.get_node(np).name, "opaque") == 1 then - for _, neighbor in ipairs(mesecon.mcl_get_neighbors(np)) do - mesecon.vm_begin() - mesecon.changesignal(neighbor.pos, minetest.get_node(neighbor.pos), vector.add(rule, neighbor.link), mesecon.state.off, 2) - if (mesecon.turnoff(neighbor.pos, vector.add(rule, neighbor.link))) then - mesecon.vm_commit() - else - mesecon.vm_abort() - end - end - end - end end end) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 3a75a23f..01584672 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -403,12 +403,24 @@ function mesecon.turnon(pos, link) 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 + -- Warning: A LOT of nodes need to be looked at for this to work + for _, r in ipairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do + local np = vector.add(f.pos, r) + for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do + local nlink = table.copy(l) + nlink.spread = false + table.insert(frontiers, {pos = np, link = nlink}) + end + end + end depth = depth + 1 end end --- Turn on an equipotential section starting at `pos`, which outputs in the direction of `link`. +-- Turn off 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, deactivating / changing all effectors along the way. @@ -464,6 +476,10 @@ function mesecon.turnoff(pos, link) depth = depth }) end + if node and f.link.spread and minetest.get_item_group(node.name, "opaque") == 1 then + -- TODO: Call turnoff on neighbors + end + depth = depth + 1 end @@ -490,8 +506,10 @@ function mesecon.rules_link_rule_all(output, rule) for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do -- Check if input accepts from output - if vector.equals(vector.add(input, inputrule), output) then - table.insert(rules, inputrule) + if vector.equals(vector.add(input, inputrule), output) then + local newrule = table.copy(inputrule) + newrule.spread = rule.spread + table.insert(rules, newrule) end end @@ -510,8 +528,11 @@ function mesecon.rules_link_rule_all_inverted(input, rule) local rules = {} for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do - if vector.equals(vector.add(output, outputrule), input) then - table.insert(rules, mesecon.invertRule(outputrule)) + if vector.equals(vector.add(output, outputrule), input) then + local newrule = table.copy(outputrule) + newrule = mesecon.invertRule(newrule) + newrule.spread = rule.spread + table.insert(rules, newrule) end end return rules diff --git a/mods/ITEMS/REDSTONE/mesecons/util.lua b/mods/ITEMS/REDSTONE/mesecons/util.lua index c848b9d3..7fd1f6fd 100644 --- a/mods/ITEMS/REDSTONE/mesecons/util.lua +++ b/mods/ITEMS/REDSTONE/mesecons/util.lua @@ -198,7 +198,12 @@ function mesecon.set_bit(binary,bit,value) end function mesecon.invertRule(r) - return vector.multiply(r, -1) + local spread = r.spread + r = vector.multiply(r, -1) + if spread then + r.spread = true + end + return r end function mesecon.tablecopy(table) -- deep table copy From f4657f79f508e1f55c07bb2430a2be06258a325a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 20 Jan 2018 19:55:25 +0100 Subject: [PATCH 25/27] Redstone: Propagate turnoff through opaque blocks --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 01584672..6c4eb91e 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -446,7 +446,7 @@ function mesecon.turnoff(pos, link) local node = mesecon.get_node_force(f.pos) if not node then - -- Area does not exist; do nothing + -- No-op elseif mesecon.is_conductor_on(node, f.link) then local rules = mesecon.conductor_get_rules(node) for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do @@ -476,8 +476,21 @@ function mesecon.turnoff(pos, link) depth = depth }) end + if node and f.link.spread and minetest.get_item_group(node.name, "opaque") == 1 then - -- TODO: Call turnoff on neighbors + -- Call turnoff on neighbors + -- Warning: A LOT of nodes need to be looked at for this to work + for _, r in ipairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do + local np = vector.add(f.pos, r) + if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then + return false + end + for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do + local nlink = table.copy(l) + nlink.spread = false + table.insert(frontiers, {pos = np, link = nlink}) + end + end end depth = depth + 1 From 01952b56fdaf70ecc3659fb176021a711f19bfcd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 22 Jan 2018 16:53:44 +0100 Subject: [PATCH 26/27] Fix bad repeater updates when next to opaque block --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 10 ++++++++-- mods/ITEMS/REDSTONE/mesecons/services.lua | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 6c4eb91e..b1eead32 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -482,8 +482,14 @@ function mesecon.turnoff(pos, link) -- Warning: A LOT of nodes need to be looked at for this to work for _, r in ipairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do local np = vector.add(f.pos, r) - if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then - return false + local n = mesecon.get_node_force(np) + if mesecon.is_receptor_on(n.name) then + local receptorrules = mesecon.receptor_get_rules(n) + for _, rr in pairs(receptorrules) do + if vector.equals(mesecon.invertRule(rr), r) then + return false + end + end end for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do local nlink = table.copy(l) diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index f7be0a5b..9de9cb46 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -84,7 +84,7 @@ mesecon.on_dignode = function(pos, node) local nnode = minetest.get_node(npos) if mesecon.is_conductor_on(nnode) then mesecon.receptor_off(npos, mesecon.conductor_get_rules(nnode)) - elseif mesecon.is_effector_on(nnode.name) then + elseif mesecon.is_effector_on(nnode.name) and mesecon.is_powered(npos) == false then mesecon.changesignal(npos, nnode, nlink, mesecon.state.off, 1) mesecon.deactivate(npos, nnode, nlink, 1) end From b62075afcb79bb46ce78d947f278e5b081f94e03 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 22 Jan 2018 17:33:06 +0100 Subject: [PATCH 27/27] Fix rail rules (kinda) --- mods/ENTITIES/mcl_minecarts/rails.lua | 33 +++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index a5be21c7..c1bf3c13 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -30,6 +30,26 @@ local register_rail = function(itemstring, tiles, def_extras, creative) minetest.register_node(itemstring, ndef) end +-- Redstone rules +local rail_rules_long = +{{x=-1, y= 0, z= 0, spread=true}, + {x= 1, y= 0, z= 0, spread=true}, + {x= 0, y=-1, z= 0, spread=true}, + {x= 0, y= 1, z= 0, spread=true}, + {x= 0, y= 0, z=-1, spread=true}, + {x= 0, y= 0, z= 1, spread=true}, + + {x= 1, y= 1, z= 0}, + {x= 1, y=-1, z= 0}, + {x=-1, y= 1, z= 0}, + {x=-1, y=-1, z= 0}, + {x= 0, y= 1, z= 1}, + {x= 0, y=-1, z= 1}, + {x= 0, y= 1, z=-1}, + {x= 0, y=-1, z=-1}} + +local rail_rules_short = mesecon.rules.pplate + local railuse = "Place them on the ground to build your railway, the rails will automatically connect to each other and will turn into curves, T-junctions, crossings and slopes as needed." -- Normal rail @@ -55,7 +75,7 @@ register_rail("mcl_minecarts:golden_rail", state = mesecon.state.off, offstate = "mcl_minecarts:golden_rail", onstate = "mcl_minecarts:golden_rail_on", - rules = mesecon.rules.default, + rules = rail_rules_long, }, }, } @@ -72,7 +92,7 @@ register_rail("mcl_minecarts:golden_rail_on", state = mesecon.state.on, offstate = "mcl_minecarts:golden_rail", onstate = "mcl_minecarts:golden_rail_on", - rules = mesecon.rules.default, + rules = rail_rules_long, }, }, drop = "mcl_minecarts:golden_rail", @@ -80,7 +100,6 @@ register_rail("mcl_minecarts:golden_rail_on", false ) - -- Activator rail (off) register_rail("mcl_minecarts:activator_rail", {"mcl_minecarts_rail_activator.png", "default_rail_curved.png^[colorize:#FF0000:96", "default_rail_t_junction.png^[colorize:#FF0000:96", "default_rail_crossing.png^[colorize:#FF0000:96"}, @@ -93,7 +112,7 @@ register_rail("mcl_minecarts:activator_rail", state = mesecon.state.off, offstate = "mcl_minecarts:activator_rail", onstate = "mcl_minecarts:activator_rail_on", - rules = mesecon.rules.default, + rules = rail_rules_long, }, }, } @@ -109,7 +128,7 @@ register_rail("mcl_minecarts:activator_rail_on", state = mesecon.state.on, offstate = "mcl_minecarts:activator_rail", onstate = "mcl_minecarts:activator_rail_on", - rules = mesecon.rules.default, + rules = rail_rules_long, }, }, drop = "mcl_minecarts:activator_rail", @@ -127,7 +146,7 @@ register_rail("mcl_minecarts:detector_rail", mesecons = { receptor = { state = mesecon.state.off, - rules = mesecon.rules.pplate, + rules = rail_rules_short, }, }, } @@ -141,7 +160,7 @@ register_rail("mcl_minecarts:detector_rail_on", mesecons = { receptor = { state = mesecon.state.on, - rules = mesecon.rules.pplate, + rules = rail_rules_short, }, }, drop = "mcl_minecarts:detector_rail",