From 9a3a835771c78b78f9e6a29848728997f2b1cc68 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Wed, 7 Oct 2015 14:02:36 +0200 Subject: [PATCH] [mesecons] Update mesecons - Also fix whitespaces in default/nodes.lua --- minetestforfun_game/mods/default/nodes.lua | 2 +- mods/mesecons/mesecons/services.lua | 8 +++++++- mods/mesecons/mesecons/settings.lua | 9 +++++++-- mods/mesecons/mesecons_button/init.lua | 2 +- mods/mesecons/mesecons_stickyblocks/init.lua | 2 +- mods/mesecons/mesecons_switch/init.lua | 2 +- mods/mesecons/mesecons_walllever/init.lua | 2 +- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/minetestforfun_game/mods/default/nodes.lua b/minetestforfun_game/mods/default/nodes.lua index 1bb515b0..a8855f8b 100755 --- a/minetestforfun_game/mods/default/nodes.lua +++ b/minetestforfun_game/mods/default/nodes.lua @@ -563,7 +563,7 @@ minetest.register_node("default:sapling", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, - groups = {snappy = 3, flammable=2, + groups = {snappy = 3, flammable=2, attached_node = 1, sapling = 1}, sounds = default.node_sound_leaves_defaults(), }) diff --git a/mods/mesecons/mesecons/services.lua b/mods/mesecons/mesecons/services.lua index 469ab956..215fb318 100755 --- a/mods/mesecons/mesecons/services.lua +++ b/mods/mesecons/mesecons/services.lua @@ -28,11 +28,13 @@ mesecon.on_placenode = function (pos, node) -- Effectors: Send changesignal and activate or deactivate if mesecon.is_effector(node.name) then local powered_rules = {} + local unpowered_rules = {} -- for each input rule, check if powered for _, r in ipairs(mesecon.effector_get_rules(node)) do local powered = mesecon.is_powered(pos, r) - if powered then table.insert(powered_rules, r) end + if powered then table.insert(powered_rules, r) + else table.insert(unpowered_rules, r) end local state = powered and mesecon.state.on or mesecon.state.off mesecon.changesignal(pos, node, r, state, 1) @@ -42,6 +44,10 @@ mesecon.on_placenode = function (pos, node) for _, r in ipairs(powered_rules) do mesecon.activate(pos, node, r, 1) end + else + for _, r in ipairs(unpowered_rules) do + mesecon.deactivate(pos, node, r, 1) + end end end end diff --git a/mods/mesecons/mesecons/settings.lua b/mods/mesecons/mesecons/settings.lua index 164cb573..50240c35 100755 --- a/mods/mesecons/mesecons/settings.lua +++ b/mods/mesecons/mesecons/settings.lua @@ -1,7 +1,12 @@ -- SETTINGS function mesecon.setting(setting, default) - if type(default) == "bool" then - return minetest.setting_getbool("mesecon."..setting) or default + if type(default) == "boolean" then + local read = minetest.setting_getbool("mesecon."..setting) + if read == nil then + return default + else + return read + end elseif type(default) == "string" then return minetest.setting_get("mesecon."..setting) or default elseif type(default) == "number" then diff --git a/mods/mesecons/mesecons_button/init.lua b/mods/mesecons/mesecons_button/init.lua index 724d75ec..f287d52b 100755 --- a/mods/mesecons/mesecons_button/init.lua +++ b/mods/mesecons/mesecons_button/init.lua @@ -40,7 +40,7 @@ minetest.register_node("mesecons_button:button_off", { }, groups = {dig_immediate=2, mesecon_needs_receiver = 1}, description = "Button", - on_punch = function (pos, node) + on_rightclick = function (pos, node) minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2}) mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node)) minetest.sound_play("mesecons_button_push", {pos=pos}) diff --git a/mods/mesecons/mesecons_stickyblocks/init.lua b/mods/mesecons/mesecons_stickyblocks/init.lua index c1eb1217..659a227a 100755 --- a/mods/mesecons/mesecons_stickyblocks/init.lua +++ b/mods/mesecons/mesecons_stickyblocks/init.lua @@ -4,7 +4,7 @@ -- All sides sticky block minetest.register_node("mesecons_stickyblocks:sticky_block_all", { description = "All-sides sticky block", - tiles = {"default_grass_footsteps.png"}, + tiles = {"default_grass.png^default_footprint.png"}, groups = {dig_immediate=2}, mvps_sticky = function (pos, node) local connected = {} diff --git a/mods/mesecons/mesecons_switch/init.lua b/mods/mesecons/mesecons_switch/init.lua index 2b3c3ee1..f52f083e 100755 --- a/mods/mesecons/mesecons_switch/init.lua +++ b/mods/mesecons/mesecons_switch/init.lua @@ -4,7 +4,7 @@ mesecon.register_node("mesecons_switch:mesecon_switch", { paramtype2="facedir", description="Switch", sounds = default.node_sound_stone_defaults(), - on_punch = function (pos, node) + on_rightclick = function (pos, node) if(mesecon.flipstate(pos, node) == "on") then mesecon.receptor_on(pos) else diff --git a/mods/mesecons/mesecons_walllever/init.lua b/mods/mesecons/mesecons_walllever/init.lua index 5ebb6f8c..9ae06555 100755 --- a/mods/mesecons/mesecons_walllever/init.lua +++ b/mods/mesecons/mesecons_walllever/init.lua @@ -15,7 +15,7 @@ mesecon.register_node("mesecons_walllever:wall_lever", { fixed = { -8/16, -8/16, 3/16, 8/16, 8/16, 8/16 }, }, sounds = default.node_sound_wood_defaults(), - on_punch = function (pos, node) + on_rightclick = function (pos, node) if(mesecon.flipstate(pos, node) == "on") then mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node)) else