summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons/presets.lua17
-rw-r--r--mesecons_button/init.lua4
-rw-r--r--mesecons_delayer/init.lua1
-rw-r--r--mesecons_detector/init.lua10
-rw-r--r--mesecons_lamp/init.lua33
-rw-r--r--mesecons_microcontroller/init.lua63
-rw-r--r--mesecons_movestones/init.lua165
-rw-r--r--mesecons_noteblock/init.lua31
-rw-r--r--mesecons_pistons/init.lua26
-rw-r--r--mesecons_powerplant/init.lua8
-rw-r--r--mesecons_pressureplates/init.lua26
-rw-r--r--mesecons_random/init.lua44
-rw-r--r--mesecons_receiver/init.lua56
-rw-r--r--mesecons_solarpanel/init.lua14
-rw-r--r--mesecons_torch/init.lua146
-rw-r--r--mesecons_walllever/init.lua73
16 files changed, 337 insertions, 380 deletions
diff --git a/mesecons/presets.lua b/mesecons/presets.lua
index ffbcae9..463a0f8 100644
--- a/mesecons/presets.lua
+++ b/mesecons/presets.lua
@@ -23,22 +23,5 @@ mesecon.rules.buttonlike =
{x = 1, y =-1, z =-1},
{x = 2, y = 0, z = 0}}
-mesecon.rules.pressurplatelike =
-{{x=0, y=1, z=-1},
-{x=0, y=0, z=-1},
-{x=0, y=-1, z=-1},
-{x=0, y=1, z=1},
-{x=0, y=-1, z=1},
-{x=0, y=0, z=1},
-{x=1, y=0, z=0},
-{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=-1, y=0, z=0},
-{x=0, y=-1, z=0},
-{x=0, y=-2, z=0},
-{x=0, y=1, z=0}}
-
mesecon.state.on = "on"
mesecon.state.off = "off"
diff --git a/mesecons_button/init.lua b/mesecons_button/init.lua
index f5c0eb9..d4e6802 100644
--- a/mesecons_button/init.lua
+++ b/mesecons_button/init.lua
@@ -32,7 +32,7 @@ minetest.register_node("mesecons_button:button_off", {
description = "Button",
on_punch = function (pos, node)
mesecon:swap_node(pos, "mesecons_button:button_on")
- local rules=mesecon.button_get_rules(node.param2)
+ local rules=mesecon.button_get_rules(node)
mesecon:receptor_on(pos, rules)
minetest.after(1, mesecon.button_turnoff, {pos=pos, param2=node.param2})
end,
@@ -81,7 +81,7 @@ minetest.register_node("mesecons_button:button_on", {
mesecon.button_turnoff = function (params)
if minetest.env:get_node(params.pos).name=="mesecons_button:button_on" then
mesecon:swap_node(params.pos, "mesecons_button:button_off")
- local rules=mesecon.button_get_rules(params.param2)
+ local rules=mesecon.button_get_rules(params)
mesecon:receptor_off(params.pos, rules)
end
end
diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua
index ca28258..6bdb72d 100644
--- a/mesecons_delayer/init.lua
+++ b/mesecons_delayer/init.lua
@@ -40,7 +40,6 @@ local delayer_turnoff = function(params)
end
local delayer_update = function(pos, node)
- print("update")
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
local time = 0
if node.name=="mesecons_delayer:delayer_off_1" then
diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua
index 1d5b214..2394e96 100644
--- a/mesecons_detector/init.lua
+++ b/mesecons_detector/init.lua
@@ -9,8 +9,7 @@ minetest.register_node("mesecons_detector:object_detector_off", {
groups = {cracky=3},
description="Player Detector",
mesecons = {receptor = {
- state = mesecon.state.off,
- rules = mesecon.rules.pressurplatelike
+ state = mesecon.state.off
}}
})
@@ -21,8 +20,7 @@ minetest.register_node("mesecons_detector:object_detector_on", {
groups = {cracky=3,not_in_creative_inventory=1},
drop = 'mesecons_detector:object_detector_off',
mesecons = {receptor = {
- state = mesecon.state.on,
- rules = mesecon.rules.pressurplatelike
+ state = mesecon.state.on
}}
})
@@ -50,7 +48,7 @@ minetest.register_abm(
end
local objpos=obj:getpos()
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
- mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_on(pos)
end
end
end,
@@ -78,7 +76,7 @@ minetest.register_abm(
end
if objectfound==0 then
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
- mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_off(pos)
end
end,
})
diff --git a/mesecons_lamp/init.lua b/mesecons_lamp/init.lua
index 553941c..d20236b 100644
--- a/mesecons_lamp/init.lua
+++ b/mesecons_lamp/init.lua
@@ -1,4 +1,7 @@
-- MESELAMPS
+-- A lamp is "is an electrical device used to create artificial light" (wikipedia)
+-- guess what?
+
minetest.register_node("mesecons_lamp:lamp_on", {
drawtype = "nodebox",
tiles = {"jeija_meselamp_on.png"},
@@ -20,8 +23,13 @@ minetest.register_node("mesecons_lamp:lamp_on", {
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
},
- groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon = 2},
+ groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1},
drop='"mesecons_lamp:lamp_off" 1',
+ mesecons = {effector = {
+ action_off = function (pos, node)
+ mesecon:swap_node(pos, "mesecons_lamp:lamp_off")
+ end
+ }}
})
minetest.register_node("mesecons_lamp:lamp_off", {
@@ -45,8 +53,13 @@ minetest.register_node("mesecons_lamp:lamp_off", {
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
},
- groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
+ groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1},
description="Meselamp",
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ mesecon:swap_node(pos, "mesecons_lamp:lamp_on")
+ end
+ }}
})
minetest.register_craft({
@@ -57,19 +70,3 @@ minetest.register_craft({
{'', '"default:glass"', ''},
}
})
-
-mesecon:register_on_signal_on(function(pos, node)
- if node.name == "mesecons_lamp:lamp_off" then
- minetest.env:add_node(pos, {name="mesecons_lamp:lamp_on", param2 = node.param2})
- nodeupdate(pos)
- end
-end)
-
-mesecon:register_on_signal_off(function(pos, node)
- if node.name == "mesecons_lamp:lamp_on" then
- minetest.env:add_node(pos, {name="mesecons_lamp:lamp_off", param2 = node.param2})
- nodeupdate(pos)
- end
-end)
-
-mesecon:register_effector("mesecons_lamp:lamp_on", "mesecons_lamp:lamp_off")
diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua
index 121eb25..19fc42d 100644
--- a/mesecons_microcontroller/init.lua
+++ b/mesecons_microcontroller/init.lua
@@ -23,6 +23,33 @@ if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
else
groups = {dig_immediate=2, mesecon = 3}
end
+local rules={}
+if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
+if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
+if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
+if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
+
+local input_rules={}
+if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end
+if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end
+if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end
+if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end
+mesecon:add_rules(nodename, rules)
+
+local mesecons = {effector =
+{
+ rules = input_rules,
+ action_change = function (pos, node)
+ update_yc(pos)
+ end
+}}
+if nodename ~= "mesecons_microcontroller:microcontroller0000" then
+ mesecons.receptor = {
+ state = mesecon.state.on,
+ rules = rules
+ }
+end
+
minetest.register_node(nodename, {
description = "Microcontroller",
drawtype = "nodebox",
@@ -101,25 +128,12 @@ minetest.register_node(nodename, {
yc_reset (pos)
update_yc(pos)
end,
+ mesecons = mesecons,
+ on_dig = function (pos, node)
+ rules = mesecon:get_rules(node.name)
+ mesecon:receptor_off(pos, rules)
+ end,
})
-
-local rules={}
-if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
-if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
-if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
-if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
-
-local input_rules={}
-if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end
-if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end
-if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end
-if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end
-mesecon:add_rules(nodename, rules)
-
-mesecon:register_effector(nodename, nodename, input_rules)
-if nodename ~= "mesecons_microcontroller:microcontroller0000" then
- mesecon:add_receptor_node(nodename, rules)
-end
end
end
end
@@ -682,16 +696,3 @@ function yc_overheat_off(pos)
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
mesecon:receptor_off(pos, rules)
end
-
-mesecon:register_on_signal_change(function(pos, node)
- if string.find(node.name, "mesecons_microcontroller:microcontroller")~=nil then
- update_yc(pos)
- end
-end)
-
-minetest.register_on_dignode(function(pos, node)
- if string.find(node.name, "mesecons_microcontroller:microcontroller") then
- rules = mesecon:get_rules(node.name)
- mesecon:receptor_off(pos, rules)
- end
-end)
diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua
index 5198a29..b17874f 100644
--- a/mesecons_movestones/init.lua
+++ b/mesecons_movestones/init.lua
@@ -1,33 +1,53 @@
-- MOVESTONE
+-- Non-sticky:
+-- Moves along mesecon lines
+-- Pushes all blocks in front of it
+--
+-- Sticky one
+-- Moves along mesecon lines
+-- Pushes all block in front of it
+-- Pull all blocks in its back
function mesecon:get_movestone_direction(pos)
- getactivated=0
+ getactivated = 0
local lpos
- local getactivated=0
- local rules=mesecon:get_rules("movestone")
-
- lpos={x=pos.x+1, y=pos.y, z=pos.z}
- for n=1, 3 do
+ local getactivated = 0
+ local rules = {
+ {x=0, y=1, z=-1},
+ {x=0, y=0, z=-1},
+ {x=0, y=-1, z=-1},
+ {x=0, y=1, z=1},
+ {x=0, y=-1, z=1},
+ {x=0, y=0, z=1},
+ {x=1, y=0, z=0},
+ {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=-1, y=0, z=0}}
+
+ lpos = {x=pos.x+1, y=pos.y, z=pos.z}
+ for n = 1, 3 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=0, y=0, z=-1}
end
end
- lpos={x=pos.x-1, y=pos.y, z=pos.z}
+ lpos = {x = pos.x-1, y = pos.y, z = pos.z}
for n=4, 6 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=0, y=0, z=1}
end
end
- lpos={x=pos.x, y=pos.y, z=pos.z+1}
+ lpos = {x = pos.x, y = pos.y, z = pos.z+1}
for n=7, 9 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=-1, y=0, z=0}
end
end
- lpos={x=pos.x, y=pos.y, z=pos.z-1}
+ lpos = {x = pos.x, y = pos.y, z = pos.z-1}
for n=10, 12 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=1, y=0, z=0}
@@ -41,8 +61,27 @@ minetest.register_node("mesecons_movestones:movestone", {
legacy_facedir_simple = true,
groups = {cracky=3},
description="Movestone",
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ local direction=mesecon:get_movestone_direction(pos)
+ if not direction then return end
+ local checknode={}
+ local collpos={x=pos.x, y=pos.y, z=pos.z}
+ repeat -- Check if it collides with a stopper
+ collpos = addPosRule(collpos, direction)
+ checknode=minetest.env:get_node(collpos)
+ if mesecon:is_mvps_stopper(checknode.name) then
+ return
+ end
+ until checknode.name=="air"
+ or checknode.name=="ignore"
+ or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
+ minetest.env:remove_node(pos)
+ mesecon:update_autoconnect(pos)
+ minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
+ end
+ }}
})
-mesecon:register_effector("mesecons_movestones:movestone", "mesecons_movestones:movestone")
minetest.register_entity("mesecons_movestones:movestone_entity", {
physical = false,
@@ -50,10 +89,6 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "cube",
- --on_activate = function(self, staticdata)
- --self.object:setsprite({x=0,y=0}, 1, 0, true)
- --self.object:setvelocity({x=-3, y=0, z=0})
- --end,
on_punch = function(self, hitter)
self.object:remove()
@@ -73,7 +108,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3})
mesecon:mvps_push(pos, direction)
- end
+ end,
})
minetest.register_craft({
@@ -85,28 +120,6 @@ minetest.register_craft({
}
})
-mesecon:register_on_signal_on(function (pos, node)
- if node.name=="mesecons_movestones:movestone" then
- local direction=mesecon:get_movestone_direction(pos)
- if not direction then return end
- local checknode={}
- local collpos={x=pos.x, y=pos.y, z=pos.z}
- repeat -- Check if it collides with a stopper
- collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
- checknode=minetest.env:get_node(collpos)
- if mesecon:is_mvps_stopper(checknode.name) then
- return
- end
- until checknode.name=="air"
- or checknode.name=="ignore"
- or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
- minetest.env:remove_node(pos)
- nodeupdate(pos)
- minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
- end
-end)
-
-
-- STICKY_MOVESTONE
@@ -118,8 +131,36 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
legacy_facedir_simple = true,
groups = {cracky=3},
description="Sticky Movestone",
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ local direction=mesecon:get_movestone_direction(pos)
+ if not direction then return end
+ local checknode={}
+ local collpos={x=pos.x, y=pos.y, z=pos.z}
+ repeat -- Check if it collides with a stopper
+ collpos = addPosRule(collpos, direction)
+ checknode=minetest.env:get_node(collpos)
+ if mesecon:is_mvps_stopper(checknode.name) then
+ return
+ end
+ until checknode.name=="air"
+ or checknode.name=="ignore"
+ or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
+ repeat -- Check if it collides with a stopper (pull direction)
+ collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
+ checknode=minetest.env:get_node(collpos)
+ if mesecon:is_mvps_stopper(checknode.name) then
+ return
+ end
+ until checknode.name=="air"
+ or checknode.name=="ignore"
+ or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
+ minetest.env:remove_node(pos)
+ mesecon:update_autoconnect(pos)
+ minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
+ end
+ }}
})
-mesecon:register_effector("mesecons_movestones:sticky_movestone", "mesecons_movestones:sticky_movestone")
minetest.register_craft({
output = '"mesecons_movestones:sticky_movestone" 2',
@@ -146,8 +187,6 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
local direction=mesecon:get_movestone_direction(colp)
if not direction then
- --or (minetest.env:get_node_or_nil(pos).name ~="air"
- --and minetest.env:get_node_or_nil(pos).name ~= nil) then
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
@@ -159,49 +198,5 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
--STICKY
mesecon:mvps_pull_all(pos, direction)
- end
+ end,
})
-
-mesecon:register_on_signal_on(function (pos, node)
- if node.name=="mesecons_movestones:sticky_movestone" then
- local direction=mesecon:get_movestone_direction(pos)
- if not direction then return end
- local checknode={}
- local collpos={x=pos.x, y=pos.y, z=pos.z}
- repeat -- Check if it collides with a stopper
- collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
- checknode=minetest.env:get_node(collpos)
- if mesecon:is_mvps_stopper(checknode.name) then
- return
- end
- until checknode.name=="air"
- or checknode.name=="ignore"
- or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
- repeat -- Check if it collides with a stopper (pull direction)
- collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
- checknode=minetest.env:get_node(collpos)
- if mesecon:is_mvps_stopper(checknode.name) then
- return
- end
- until checknode.name=="air"
- or checknode.name=="ignore"
- or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
- minetest.env:remove_node(pos)
- nodeupdate(pos)
- minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
- end
-end)
-
-mesecon:add_rules("movestone", {
-{x=0, y=1, z=-1},
-{x=0, y=0, z=-1},
-{x=0, y=-1, z=-1},
-{x=0, y=1, z=1},
-{x=0, y=-1, z=1},
-{x=0, y=0, z=1},
-{x=1, y=0, z=0},
-{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=-1, y=0, z=0}})
diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua
index 0b05bbb..073524c 100644
--- a/mesecons_noteblock/init.lua
+++ b/mesecons_noteblock/init.lua
@@ -1,15 +1,25 @@
minetest.register_node("mesecons_noteblock:noteblock", {
description = "Noteblock",
tiles = {"mesecons_noteblock.png"},
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
drawtype = "allfaces_optional",
visual_scale = 1.3,
paramtype="light",
after_place_node = function(pos)
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
- end
+ end,
+ on_punch = function (pos, node) -- change sound when punched
+ local param2 = node.param2+1
+ if param2==12 then param2=0 end
+ minetest.env:add_node(pos, {name = node.name, param2 = param2})
+ mesecon.noteblock_play(pos, param2)
+ end,
+ mesecons = {effector = { -- play sound when activated
+ action_on = function (pos, node)
+ mesecon.noteblock_play(pos, node.param2)
+ end
+ }}
})
-mesecon:register_effector("mesecons_noteblock:noteblock", "mesecons_noteblock:noteblock")
minetest.register_craft({
output = '"mesecons_noteblock:noteblock" 1',
@@ -20,15 +30,6 @@ minetest.register_craft({
}
})
-minetest.register_on_punchnode(function (pos, node)
- if node.name=="mesecons_noteblock:noteblock" then
- local param2 = node.param2+1
- if param2==12 then param2=0 end
- minetest.env:add_node(pos, {name=node.name, param2=param2})
- mesecon.noteblock_play(pos, param2)
- end
-end)
-
mesecon.noteblock_play = function (pos, param2)
local soundname
if param2==8 then
@@ -75,9 +76,3 @@ mesecon.noteblock_play = function (pos, param2)
minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,})
end
-
-mesecon:register_on_signal_on(function(pos, node)
- if node.name=="mesecons_noteblock:noteblock" then
- mesecon.noteblock_play(pos, node.param2)
- end
-end)
diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua
index 935ca66..dd3f599 100644
--- a/mesecons_pistons/init.lua
+++ b/mesecons_pistons/init.lua
@@ -1,5 +1,11 @@
--PISTONS
+local update = function(pos, node)
+ local timer = minetest.env:get_node_timer(pos)
+ timer:stop()
+ timer:start(0)
+end
+
minetest.register_node("mesecons_pistons:piston_normal", {
description = "Piston",
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"},
@@ -25,8 +31,10 @@ minetest.register_node("mesecons_pistons:piston_normal", {
end
return false
end,
+ mesecons = {effector={
+ action_change = update
+ }}
})
-mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
minetest.register_node("mesecons_pistons:piston_sticky", {
description = "Sticky Piston",
@@ -53,8 +61,10 @@ minetest.register_node("mesecons_pistons:piston_sticky", {
end
return false
end,
+ mesecons = {effector={
+ action_change = update
+ }}
})
-mesecon:register_effector("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky")
minetest.register_craft({
output = '"mesecons_pistons:piston_normal" 2',
@@ -127,18 +137,6 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal")
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky")
-local update = function(pos, node)
- if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
- return
- end
-
- local timer = minetest.env:get_node_timer(pos)
- timer:stop()
- timer:start(0)
-end
-mesecon:register_on_signal_on(update) --push action
-mesecon:register_on_signal_off(update) --pull action
-
function mesecon:piston_push(pos)
local node = minetest.env:get_node(pos)
local dir = mesecon:piston_get_direction(node)
diff --git a/mesecons_powerplant/init.lua b/mesecons_powerplant/init.lua
index a45f5cc..006fc19 100644
--- a/mesecons_powerplant/init.lua
+++ b/mesecons_powerplant/init.lua
@@ -1,4 +1,5 @@
- -- The POWER_PLANT
+-- The POWER_PLANT
+-- Just emits power. always.
minetest.register_node("mesecons_powerplant:power_plant", {
drawtype = "plantlike",
@@ -14,6 +15,9 @@ minetest.register_node("mesecons_powerplant:power_plant", {
type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
},
+ mesecons = {receptor = {
+ state = mesecon.state.on
+ }}
})
minetest.register_craft({
@@ -24,5 +28,3 @@ minetest.register_craft({
{'"default:sapling"'},
}
})
-
-mesecon:add_receptor_node("mesecons_powerplant:power_plant")
diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua
index f7a2edd..2e88d2f 100644
--- a/mesecons_pressureplates/init.lua
+++ b/mesecons_pressureplates/init.lua
@@ -25,7 +25,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
local objpos=obj:getpos()
if objpos.y>pos.y-1 and objpos.y<pos.y then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_on"})
- mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_on(pos)
end
end
return true
@@ -57,7 +57,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
local objs = minetest.env:get_objects_inside_radius(pos, 1)
if objs[1]==nil then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"})
- mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_off(pos)
end
return true
end,
@@ -92,7 +92,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2},
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
description="Stone Pressure Plate",
on_timer = function(pos, elapsed)
@@ -101,7 +101,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
local objpos=obj:getpos()
if objpos.y>pos.y-1 and objpos.y<pos.y then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_on"})
- mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_on(pos)
end
end
return true
@@ -110,6 +110,10 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
+
+ mesecons = {receptor = {
+ state = mesecon.state.off
+ }}
})
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
@@ -126,14 +130,14 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
},
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
on_timer = function(pos, elapsed)
local objs = minetest.env:get_objects_inside_radius(pos, 1)
if objs[1]==nil then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_off"})
- mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
+ mesecon:receptor_off(pos)
end
return true
end,
@@ -141,6 +145,10 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
+
+ mesecons = {receptor = {
+ state = mesecon.state.off
+ }}
})
minetest.register_craft({
@@ -149,9 +157,3 @@ minetest.register_craft({
{'"default:cobble"', '"default:cobble"'},
}
})
-
-mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on", mesecon:get_rules("pressureplate"))
-mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off", mesecon:get_rules("pressureplate"))
-
-mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on", mesecon:get_rules("pressureplate"))
-mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off", mesecon:get_rules("pressureplate"))
diff --git a/mesecons_random/init.lua b/mesecons_random/init.lua
index 4011217..4fc2f6e 100644
--- a/mesecons_random/init.lua
+++ b/mesecons_random/init.lua
@@ -3,12 +3,16 @@
minetest.register_node("mesecons_random:removestone", {
tiles = {"jeija_removestone.png"},
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
- groups = {cracky=3, mesecon=2},
+ groups = {cracky=3},
description="Removestone",
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ minetest.env:remove_node(pos)
+ mesecon:update_autoconnect(pos)
+ end
+ }}
})
-mesecon:register_effector(nil, "mesecons_random:removestone")
-
minetest.register_craft({
output = 'mesecons_random:removestone 4',
recipe = {
@@ -18,12 +22,6 @@ minetest.register_craft({
}
})
-mesecon:register_on_signal_on(function(pos, node)
- if node.name == "mesecons_random:removestone" then
- minetest.env:remove_node(pos)
- end
-end)
-
-- GHOSTSTONE
minetest.register_node("mesecons_random:ghoststone", {
@@ -31,8 +29,13 @@ minetest.register_node("mesecons_random:ghoststone", {
tiles = {"jeija_ghoststone.png"},
is_ground_content = true,
inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"),
- groups = {cracky=3, mesecon=2},
+ groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ minetest.env:add_node(pos, {name="mesecons_random:ghoststone_active"})
+ end
+ }}
})
minetest.register_node("mesecons_random:ghoststone_active", {
@@ -41,10 +44,13 @@ minetest.register_node("mesecons_random:ghoststone_active", {
walkable = false,
diggable = false,
sunlight_propagates = true,
- groups = {mesecon=2},
+ mesecons = {effector = {
+ action_off = function (pos, node)
+ minetest.env:add_node(pos, {name="mesecons_random:ghoststone"})
+ end
+ }}
})
-mesecon:register_effector("mesecons_random:ghoststone_active", "mesecons_random:ghoststone")
minetest.register_craft({
output = 'mesecons_random:ghoststone 4',
@@ -54,17 +60,3 @@ minetest.register_craft({
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
}
})
-
-mesecon:register_on_signal_on(function(pos, node)
- if node.name == "mesecons_random:ghoststone" then
- minetest.env:add_node(pos, {name="mesecons_random:ghoststone_active"})
- nodeupdate(pos)
- end
-end)
-
-mesecon:register_on_signal_off(function(pos, node)
- if node.name == "mesecons_random:ghoststone_active" then
- minetest.env:add_node(pos, {name="mesecons_random:ghoststone"})
- nodeupdate(pos)
- end
-end) \ No newline at end of file
diff --git a/mesecons_receiver/init.lua b/mesecons_receiver/init.lua
index e67b980..d830d19 100644
--- a/mesecons_receiver/init.lua
+++ b/mesecons_receiver/init.lua
@@ -5,6 +5,19 @@ rcvboxes = {
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire
}
+local receiver_get_rules = function (node)
+ local rules = { {x = 1, y = 0, z = 0},
+ {x = -2, y = 0, z = 0}}
+ if node.param2 == 2 then
+ rules = mesecon:rotate_rules_left(rules)
+ elseif node.param2 == 3 then
+ rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
+ elseif node.param2 == 0 then
+ rules = mesecon:rotate_rules_right(rules)
+ end
+ return rules
+end
+
minetest.register_node("mesecons_receiver:receiver_on", {
drawtype = "nodebox",
tiles = {
@@ -26,9 +39,13 @@ minetest.register_node("mesecons_receiver:receiver_on", {
type = "fixed",
fixed = rcvboxes
},
- groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
-
+ mesecons = {conductor = {
+ state = mesecon.state.on,
+ rules = receiver_get_rules,
+ offstate = "mesecons_receiver:receiver_off"
+ }}
})
minetest.register_node("mesecons_receiver:receiver_off", {
@@ -53,8 +70,13 @@ minetest.register_node("mesecons_receiver:receiver_off", {
type = "fixed",
fixed = rcvboxes
},
- groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
+ mesecons = {conductor = {
+ state = mesecon.state.off,
+ rules = receiver_get_rules,
+ onstate = "mesecons_receiver:receiver_on"
+ }}
})
mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}})
@@ -65,34 +87,6 @@ mesecon:add_rules("receiver_pos_all", {
{x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}})
-mesecon:add_rules("mesecon_receiver", {
-{x = 1, y = 0, z = 0},
-{x = -2, y = 0, z = 0},})
-
-mesecon:add_rules("mesecon_receiver_all", {
-{x = 1, y = 0, z = 0},
-{x =-2, y = 0, z = 0},
-{x =-1, y = 0, z = 0},
-{x = 2, y = 0, z = 0},
-{x = 0, y = 0, z = 1},
-{x = 0, y = 0, z =-2},
-{x = 1, y = 0, z =-1},
-{x =-2, y = 0, z = 2},})
-
-function receiver_get_rules(param2)
- local rules = mesecon:get_rules("mesecon_receiver")
- if param2 == 2 then
- rules = mesecon:rotate_rules_left(rules)
- elseif param2 == 3 then
- rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
- elseif param2 == 0 then
- rules = mesecon:rotate_rules_right(rules)
- end
- return rules
-end
-
-mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules)
-
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
local rules = mesecon:get_rules("receiver_pos")
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
diff --git a/mesecons_solarpanel/init.lua b/mesecons_solarpanel/init.lua
index 343dee1..b8f3ac0 100644
--- a/mesecons_solarpanel/init.lua
+++ b/mesecons_solarpanel/init.lua
@@ -21,8 +21,10 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
},
drop = "mesecons_solarpanel:solar_panel_off",
- groups = {dig_immediate=3, mesecon = 2, not_in_creative_inventory = 1},
- description="Solar Panel",
+ groups = {dig_immediate=3, not_in_creative_inventory = 1},
+ mesecons = {receptor = {
+ state = mesecon.state.on
+ }}
})
-- Solar Panel
@@ -47,8 +49,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
},
- groups = {dig_immediate=3, mesecon = 2},
+ groups = {dig_immediate=3},
description="Solar Panel",
+ mesecons = {receptor = {
+ state = mesecon.state.off
+ }}
})
minetest.register_craft({
@@ -86,6 +91,3 @@ minetest.register_abm(
end
end,
})
-
-mesecon:add_receptor_node("mesecons_solarpanel:solar_panel_on")
-mesecon:add_receptor_node_off("mesecons_solarpanel:solar_panel_off")
diff --git a/mesecons_torch/init.lua b/mesecons_torch/init.lua
index d7a9596..8b9a59b 100644
--- a/mesecons_torch/init.lua
+++ b/mesecons_torch/init.lua
@@ -1,30 +1,74 @@
--MESECON TORCHES
+local torch_get_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}}
+ if node.param2 == 5 then
+ rules=mesecon:rotate_rules_right(rules)
+ elseif node.param2 == 2 then
+ rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees
+ elseif node.param2 == 4 then
+ rules=mesecon:rotate_rules_left(rules)
+ elseif node.param2 == 1 then
+ rules=mesecon:rotate_rules_down(rules)
+ elseif node.param2 == 0 then
+ rules=mesecon:rotate_rules_up(rules)
+ end
+ return rules
+end
+
+local torch_get_input_rules = function(node)
+ local rules = {x=0, y=0, z=0}
+
+ if node.param2 == 4 then
+ rules.z = -2
+ elseif node.param2 == 2 then
+ rules.x = -2
+ elseif node.param2 == 5 then
+ rules.z = 2
+ elseif node.param2 == 3 then
+ rules.x = 2
+ elseif node.param2 == 1 then
+ rules.y = 2
+ elseif node.param2 == 0 then
+ rules.y = -2
+ end
+ return rules
+end
+
minetest.register_craft({
- output = '"mesecons_torch:mesecon_torch_on" 4',
- recipe = {
- {"group:mesecon_conductor_craftable"},
- {"default:stick"},
- }
+ output = '"mesecons_torch:mesecon_torch_on" 4',
+ recipe = {
+ {"group:mesecon_conductor_craftable"},
+ {"default:stick"},
+ }
})
minetest.register_node("mesecons_torch:mesecon_torch_off", {
- drawtype = "torchlike",
- tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"},
- inventory_image = "jeija_torches_off.png",
- paramtype = "light",
- walkable = false,
- paramtype2 = "wallmounted",
- selection_box = {
- type = "wallmounted",
- wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
- wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
- wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
- },
- legacy_wallmounted = true,
- groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon = 2},
- drop = '"mesecons_torch:mesecon_torch_on" 1',
- description="Mesecon Torch",
+ drawtype = "torchlike",
+ tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"},
+ inventory_image = "jeija_torches_off.png",
+ paramtype = "light",
+ walkable = false,
+ paramtype2 = "wallmounted",
+ selection_box = {
+ type = "wallmounted",
+ wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
+ wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
+ wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
+ },
+ legacy_wallmounted = true,
+ groups = {dig_immediate=3,not_in_creative_inventory=1},
+ drop = '"mesecons_torch:mesecon_torch_on" 1',
+ description="Mesecon Torch",
+ mesecons = {receptor = {
+ state = mesecon.state.off,
+ rules = torch_get_rules
+ }}
})
minetest.register_node("mesecons_torch:mesecon_torch_on", {
@@ -43,9 +87,13 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", {
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
},
legacy_wallmounted = true,
- groups = {dig_immediate=3, mesecon = 2},
+ groups = {dig_immediate=3},
light_source = LIGHT_MAX-5,
description="Mesecon Torch",
+ mesecons = {receptor = {
+ state = mesecon.state.on,
+ rules = torch_get_rules
+ }}
})
minetest.register_abm({
@@ -53,70 +101,24 @@ minetest.register_abm({
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- local rules=mesecon.torch_get_rules(minetest.env:get_node(pos).param2)
- local pa = mesecon.torch_get_input_rules(node.param2)
+ local node = minetest.env:get_node(pos)
+ local pa = torch_get_input_rules(node)
local postc = {x=pos.x-pa.x, y=pos.y-pa.y, z=pos.z-pa.z}
if mesecon:is_power_on(postc) then
if node.name ~= "mesecons_torch:mesecon_torch_off" then
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_off",param2=node.param2})
- mesecon:receptor_off(pos, rules_string)
+ mesecon:receptor_off(pos, torch_get_rules(node))
end
else
if node.name ~= "mesecons_torch:mesecon_torch_on" then
minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_on",param2=node.param2})
- mesecon:receptor_on(pos, rules_string)
+ mesecon:receptor_on(pos, torch_get_rules(node))
end
end
end
})
-mesecon.torch_get_rules = function(param2)
- local rules=mesecon:get_rules("mesecontorch")
- if param2 == 5 then
- rules=mesecon:rotate_rules_right(rules)
- elseif param2 == 2 then
- rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees
- elseif param2 == 4 then
- rules=mesecon:rotate_rules_left(rules)
- elseif param2 == 1 then
- rules=mesecon:rotate_rules_down(rules)
- elseif param2 == 0 then
- rules=mesecon:rotate_rules_up(rules)
- end
- return rules
-end
-
-mesecon.torch_get_input_rules = function(param2)
- local rules = {x=0, y=0, z=0}
-
- if param2 == 4 then
- rules.z = -2
- elseif param2 == 2 then
- rules.x = -2
- elseif param2 == 5 then
- rules.z = 2
- elseif param2 == 3 then
- rules.x = 2
- elseif param2 == 1 then
- rules.y = 2
- elseif param2 == 0 then
- rules.y = -2
- end
- return rules
-end
-
-mesecon:add_rules("mesecontorch",
-{{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}})
-
-mesecon:add_receptor_node("mesecons_torch:mesecon_torch_on", nil, mesecon.torch_get_rules)
-mesecon:add_receptor_node_off("mesecons_torch:mesecon_torch_off", nil, mesecon.torch_get_rules)
-mesecon:register_effector("mesecons_torch:mesecon_torch_on","mesecons_torch:mesecon_torch_off", nil, mesecon.torch_get_input_rules)
-
-- Param2 Table (Block Attached To)
-- 5 = z-1
-- 3 = x-1
diff --git a/mesecons_walllever/init.lua b/mesecons_walllever/init.lua
index 36c4b8f..da427be 100644
--- a/mesecons_walllever/init.lua
+++ b/mesecons_walllever/init.lua
@@ -1,4 +1,22 @@
-- WALL LEVER
+local walllever_get_rules = function(node)
+ local rules = {
+ {x = 1, y = 0, z = 0},
+ {x = 1, y = 1, z = 0},
+ {x = 1, y =-1, z = 0},
+ {x = 1, y =-1, z = 1},
+ {x = 1, y =-1, z =-1},
+ {x = 2, y = 0, z = 0}}
+ if node.param2 == 2 then
+ rules=mesecon:rotate_rules_left(rules)
+ elseif node.param2 == 3 then
+ rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
+ elseif node.param2 == 0 then
+ rules=mesecon:rotate_rules_right(rules)
+ end
+ return rules
+end
+
minetest.register_node("mesecons_walllever:wall_lever_off", {
drawtype = "nodebox",
tiles = {
@@ -27,8 +45,16 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
{ -1/16, -8/16, 4/16, 1/16, 0, 6/16 }} -- the lever itself.
},
- groups = {dig_immediate=2, mesecon = 3, mesecon_needs_receiver = 1},
+ groups = {dig_immediate=2, mesecon_needs_receiver = 1},
description="Lever",
+ on_punch = function (pos, node)
+ mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
+ mesecon:receptor_on(pos, walllever_get_rules(node))
+ end,
+ mesecon = {receptor = {
+ rules = walllever_get_rules,
+ state = mesecon.state.off
+ }}
})
minetest.register_node("mesecons_walllever:wall_lever_on", {
drawtype = "nodebox",
@@ -61,19 +87,16 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1},
drop = '"mesecons_walllever:wall_lever_off" 1',
description="Lever",
+ on_punch = function (pos, node)
+ mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
+ mesecon:receptor_off(pos, walllever_get_rules(node))
+ end,
+ mesecon = {receptor = {
+ rules = walllever_get_rules,
+ state = mesecon.state.on
+ }}
})
-minetest.register_on_punchnode(function(pos, node, puncher)
- if node.name == "mesecons_walllever:wall_lever_off" then
- minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_on",param2=node.param2})
- mesecon:receptor_on(pos, mesecon.walllever_get_rules(node.param2))
- end
- if node.name == "mesecons_walllever:wall_lever_on" then
- minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_off",param2=node.param2})
- mesecon:receptor_off(pos, mesecon.walllever_get_rules(node.param2))
- end
-end)
-
minetest.register_craft({
output = '"mesecons_walllever:wall_lever_off" 2',
recipe = {
@@ -82,29 +105,3 @@ minetest.register_craft({
{'"default:stick"'},
}
})
-
-mesecon:add_rules("walllever", {
-{x = 1, y = 0, z = 0},
-{x = 1, y = 1, z = 0},
-{x = 1, y =-1, z = 0},
-{x = 1, y =-1, z = 1},
-{x = 1, y =-1, z =-1},
-{x = 2, y = 0, z = 0},})
-
-
-mesecon.walllever_get_rules = function(param2)
- local rules=mesecon:get_rules("walllever")
- if param2 == 2 then
- rules=mesecon:rotate_rules_left(rules)
- end
- if param2 == 3 then
- rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
- end
- if param2 == 0 then
- rules=mesecon:rotate_rules_right(rules)
- end
- return rules
-end
-
-mesecon:add_receptor_node("mesecons_walllever:wall_lever_on", nil, mesecon.walllever_get_rules)
-mesecon:add_receptor_node_off("mesecons_walllever:wall_lever_off", nil, mesecon.walllever_get_rules)