mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-24 00:40:20 +01:00
[mesecons] Update mesecons
- Also fix whitespaces in default/nodes.lua
This commit is contained in:
parent
0b2f6d8453
commit
9a3a835771
@ -28,11 +28,13 @@ mesecon.on_placenode = function (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
|
||||||
local powered_rules = {}
|
local powered_rules = {}
|
||||||
|
local unpowered_rules = {}
|
||||||
|
|
||||||
-- for each input rule, check if powered
|
-- for each input rule, check if powered
|
||||||
for _, r in ipairs(mesecon.effector_get_rules(node)) do
|
for _, r in ipairs(mesecon.effector_get_rules(node)) do
|
||||||
local powered = mesecon.is_powered(pos, r)
|
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
|
local state = powered and mesecon.state.on or mesecon.state.off
|
||||||
mesecon.changesignal(pos, node, r, state, 1)
|
mesecon.changesignal(pos, node, r, state, 1)
|
||||||
@ -42,6 +44,10 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
for _, r in ipairs(powered_rules) do
|
for _, r in ipairs(powered_rules) do
|
||||||
mesecon.activate(pos, node, r, 1)
|
mesecon.activate(pos, node, r, 1)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
for _, r in ipairs(unpowered_rules) do
|
||||||
|
mesecon.deactivate(pos, node, r, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
-- SETTINGS
|
-- SETTINGS
|
||||||
function mesecon.setting(setting, default)
|
function mesecon.setting(setting, default)
|
||||||
if type(default) == "bool" then
|
if type(default) == "boolean" then
|
||||||
return minetest.setting_getbool("mesecon."..setting) or default
|
local read = minetest.setting_getbool("mesecon."..setting)
|
||||||
|
if read == nil then
|
||||||
|
return default
|
||||||
|
else
|
||||||
|
return read
|
||||||
|
end
|
||||||
elseif type(default) == "string" then
|
elseif type(default) == "string" then
|
||||||
return minetest.setting_get("mesecon."..setting) or default
|
return minetest.setting_get("mesecon."..setting) or default
|
||||||
elseif type(default) == "number" then
|
elseif type(default) == "number" then
|
||||||
|
@ -40,7 +40,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||||
description = "Button",
|
description = "Button",
|
||||||
on_punch = function (pos, node)
|
on_rightclick = function (pos, node)
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- All sides sticky block
|
-- All sides sticky block
|
||||||
minetest.register_node("mesecons_stickyblocks:sticky_block_all", {
|
minetest.register_node("mesecons_stickyblocks:sticky_block_all", {
|
||||||
description = "All-sides sticky block",
|
description = "All-sides sticky block",
|
||||||
tiles = {"default_grass_footsteps.png"},
|
tiles = {"default_grass.png^default_footprint.png"},
|
||||||
groups = {dig_immediate=2},
|
groups = {dig_immediate=2},
|
||||||
mvps_sticky = function (pos, node)
|
mvps_sticky = function (pos, node)
|
||||||
local connected = {}
|
local connected = {}
|
||||||
|
@ -4,7 +4,7 @@ mesecon.register_node("mesecons_switch:mesecon_switch", {
|
|||||||
paramtype2="facedir",
|
paramtype2="facedir",
|
||||||
description="Switch",
|
description="Switch",
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_punch = function (pos, node)
|
on_rightclick = function (pos, node)
|
||||||
if(mesecon.flipstate(pos, node) == "on") then
|
if(mesecon.flipstate(pos, node) == "on") then
|
||||||
mesecon.receptor_on(pos)
|
mesecon.receptor_on(pos)
|
||||||
else
|
else
|
||||||
|
@ -15,7 +15,7 @@ mesecon.register_node("mesecons_walllever:wall_lever", {
|
|||||||
fixed = { -8/16, -8/16, 3/16, 8/16, 8/16, 8/16 },
|
fixed = { -8/16, -8/16, 3/16, 8/16, 8/16, 8/16 },
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_punch = function (pos, node)
|
on_rightclick = function (pos, node)
|
||||||
if(mesecon.flipstate(pos, node) == "on") then
|
if(mesecon.flipstate(pos, node) == "on") then
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user