summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons/internal.lua4
-rw-r--r--mesecons/presets.lua17
-rw-r--r--mesecons/settings.lua1
-rw-r--r--mesecons_detector/init.lua27
-rw-r--r--mesecons_extrawires/crossing.lua2
-rw-r--r--mesecons_extrawires/init.lua3
-rw-r--r--mesecons_extrawires/tjunction.lua54
-rw-r--r--mesecons_hydroturbine/init.lua16
-rw-r--r--mesecons_insulated/init.lua33
-rw-r--r--mesecons_pressureplates/init.lua17
10 files changed, 98 insertions, 76 deletions
diff --git a/mesecons/internal.lua b/mesecons/internal.lua
index d438a53..8337f62 100644
--- a/mesecons/internal.lua
+++ b/mesecons/internal.lua
@@ -290,7 +290,7 @@ function mesecon:turnon(pos)
if mesecon:is_conductor_off(node.name) then
local rules = mesecon:conductor_get_rules(node)
- minetest.env:add_node(pos, {name=mesecon:get_conductor_on(node.name), param2 = node.param2})
+ mesecon:swap_node(pos, mesecon:get_conductor_on(node.name))
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
@@ -314,7 +314,7 @@ function mesecon:turnoff(pos) --receptor rules used because output could have be
if mesecon:is_conductor_on(node.name) then
local rules = mesecon:conductor_get_rules(node)
- minetest.env:add_node(pos, {name=mesecon:get_conductor_off(node.name), param2 = node.param2})
+ mesecon:swap_node(pos, mesecon:get_conductor_off(node.name))
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
diff --git a/mesecons/presets.lua b/mesecons/presets.lua
index 463a0f8..ffbcae9 100644
--- a/mesecons/presets.lua
+++ b/mesecons/presets.lua
@@ -23,5 +23,22 @@ 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/settings.lua b/mesecons/settings.lua
index db084c6..398ee6d 100644
--- a/mesecons/settings.lua
+++ b/mesecons/settings.lua
@@ -2,3 +2,4 @@
BLINKY_PLANT_INTERVAL = 3
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
PRESSURE_PLATE_INTERVAL = 0.1
+OBJECT_DETECTOR_RADIUS = 6
diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua
index cbee787..1d5b214 100644
--- a/mesecons_detector/init.lua
+++ b/mesecons_detector/init.lua
@@ -1,19 +1,29 @@
---SHORT RANGE DETECTORS
+-- Object detector
+-- Detects all entities in a certain radius
+-- The radius can be specified in mesecons/settings.lua
+
minetest.register_node("mesecons_detector:object_detector_off", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"},
paramtype = "light",
walkable = true,
- groups = {cracky=3, mesecon = 2},
+ groups = {cracky=3},
description="Player Detector",
+ mesecons = {receptor = {
+ state = mesecon.state.off,
+ rules = mesecon.rules.pressurplatelike
+ }}
})
minetest.register_node("mesecons_detector:object_detector_on", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
paramtype = "light",
walkable = true,
- groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2},
+ groups = {cracky=3,not_in_creative_inventory=1},
drop = 'mesecons_detector:object_detector_off',
- description="Player Detector",
+ mesecons = {receptor = {
+ state = mesecon.state.on,
+ rules = mesecon.rules.pressurplatelike
+ }}
})
minetest.register_craft({
@@ -30,9 +40,9 @@ minetest.register_abm(
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- local objs = minetest.env:get_objects_inside_radius(pos, 6)
+ local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
for k, obj in pairs(objs) do
- if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then -- Detected object is not piston pusher - will be changed if every entity has a type (like entity_type=mob)
+ if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then
if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then
if obj:get_player_name()~=minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text") then
return
@@ -51,7 +61,7 @@ minetest.register_abm(
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- local objs = minetest.env:get_objects_inside_radius(pos, 6)
+ local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
local objectfound=0
for k, obj in pairs(objs) do
if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj~=nil
@@ -72,6 +82,3 @@ minetest.register_abm(
end
end,
})
-
-mesecon:add_receptor_node("mesecons_detector:object_detector_on", mesecon:get_rules("pressureplate"))
-mesecon:add_receptor_node_off("mesecons_detector:object_detector_off", mesecon:get_rules("pressureplate"))
diff --git a/mesecons_extrawires/crossing.lua b/mesecons_extrawires/crossing.lua
index 9ceb9ac..53f12b2 100644
--- a/mesecons_extrawires/crossing.lua
+++ b/mesecons_extrawires/crossing.lua
@@ -1,3 +1,5 @@
+-- CODE NOT ACTIVE
+
for x=-1, 1 do for z=-1, 1 do
rules = {}
nodename = "mesecons_extrawires:crossing"
diff --git a/mesecons_extrawires/init.lua b/mesecons_extrawires/init.lua
index a8e937f..c9e0773 100644
--- a/mesecons_extrawires/init.lua
+++ b/mesecons_extrawires/init.lua
@@ -1,2 +1,3 @@
-dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
+-- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
+-- The crossing code is not active right now because it is hard to maintain
dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua");
diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua
index 93eac0a..9f0c125 100644
--- a/mesecons_extrawires/tjunction.lua
+++ b/mesecons_extrawires/tjunction.lua
@@ -9,6 +9,22 @@ local tjunction_selectionbox = {
fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 },
}
+local tjunction_get_rules = function (node)
+ local rules =
+ {{x = 1, y = 0, z = 0},
+ {x =-1, y = 0, z = 0},
+ {x = 0, y = 0, z = -1}}
+
+ if node.param2 == 1 then
+ rules = mesecon:rotate_rules_left(rules)
+ elseif node.param2 == 2 then
+ rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
+ elseif node.param2 == 3 then
+ rules = mesecon:rotate_rules_right(rules)
+ end
+ return rules
+end
+
minetest.register_node("mesecons_extrawires:tjunction_on", {
drawtype = "nodebox",
tiles = {
@@ -27,7 +43,12 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
node_box = tjunction_nodebox,
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off",
-
+ mesecons = {conductor =
+ {
+ state = mesecon.state.on,
+ rules = tjunction_get_rules,
+ offstate = "mesecons_extrawires:tjunction_off"
+ }}
})
minetest.register_node("mesecons_extrawires:tjunction_off", {
@@ -48,6 +69,12 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
selection_box = tjunction_selectionbox,
node_box = tjunction_nodebox,
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1},
+ mesecons = {conductor =
+ {
+ state = mesecon.state.off,
+ rules = tjunction_get_rules,
+ onstate = "mesecons_extrawires:tjunction_on"
+ }}
})
minetest.register_craft({
@@ -58,28 +85,3 @@ minetest.register_craft({
{"", "mesecons_insulated:insulated_off", ""},
}
})
-
-mesecon:add_rules("tjunction_all", { --all possible 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},})
-
-mesecon:add_rules("tjunction", {
-{x = 1, y = 0, z = 0},
-{x =-1, y = 0, z = 0},
-{x = 0, y = 0, z = -1},})
-
-function tjunction_get_rules(param2)
- local rules = mesecon:get_rules("tjunction")
- if param2 == 1 then
- rules = mesecon:rotate_rules_left(mesecon:get_rules("tjunction"))
- elseif param2 == 2 then
- rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(mesecon:get_rules("tjunction")))
- elseif param2 == 3 then
- rules = mesecon:rotate_rules_right(mesecon:get_rules("tjunction"))
- end
- return rules
-end
-
-mesecon:register_conductor("mesecons_extrawires:tjunction_on", "mesecons_extrawires:tjunction_off", mesecon:get_rules("tjunction_all"), tjunction_get_rules)
diff --git a/mesecons_hydroturbine/init.lua b/mesecons_hydroturbine/init.lua
index 872d18d..70b7d28 100644
--- a/mesecons_hydroturbine/init.lua
+++ b/mesecons_hydroturbine/init.lua
@@ -1,9 +1,12 @@
-- HYDRO_TURBINE
+-- Water turbine:
+-- Active if flowing >water< above it
+-- (does not work with other liquids)
minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
drawtype = "nodebox",
tiles = {"jeija_hydro_turbine_off.png"},
- groups = {dig_immediate=2, mesecon = 2},
+ groups = {dig_immediate=2},
description="Water Turbine",
paramtype = "light",
selection_box = {
@@ -20,13 +23,16 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
{-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
{-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
},
+ mesecons = {receptor = {
+ state = mesecon.state.off
+ }}
})
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
drawtype = "nodebox",
tiles = {"jeija_hydro_turbine_on.png"},
drop = '"mesecons_hydroturbine:hydro_turbine_off" 1',
- groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
+ groups = {dig_immediate=2,not_in_creative_inventory=1},
description="Water Turbine",
paramtype = "light",
selection_box = {
@@ -43,6 +49,9 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
{-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
{-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
},
+ mesecons = {receptor = {
+ state = mesecon.state.on
+ }}
})
@@ -74,9 +83,6 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
end,
})
-mesecon:add_receptor_node("mesecons_hydroturbine:hydro_turbine_on")
-mesecon:add_receptor_node_off("mesecons_hydroturbine:hydro_turbine_off")
-
minetest.register_craft({
output = '"mesecons_hydroturbine:hydro_turbine_off" 2',
recipe = {
diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua
index 5b48716..fe929d6 100644
--- a/mesecons_insulated/init.lua
+++ b/mesecons_insulated/init.lua
@@ -21,9 +21,13 @@ minetest.register_node("mesecons_insulated:insulated_on", {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
- groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
+ groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off",
-
+ mesecons = {conductor = {
+ state = mesecon.state.on,
+ offstate = "mesecons_insulated:insulated_off",
+ rules = insulated_wire_get_rules
+ }}
})
minetest.register_node("mesecons_insulated:insulated_off", {
@@ -49,7 +53,12 @@ minetest.register_node("mesecons_insulated:insulated_off", {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
- groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1},
+ groups = {dig_immediate = 3},
+ mesecons = {conductor = {
+ state = mesecon.state.off,
+ onstate = "mesecons_insulated:insulated_on",
+ rules = insulated_wire_get_rules
+ }}
})
minetest.register_craft({
@@ -61,21 +70,15 @@ minetest.register_craft({
}
})
-mesecon:add_rules("insulated_all", { --all possible 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},})
-
mesecon:add_rules("insulated", {
{x = 1, y = 0, z = 0},
-{x =-1, y = 0, z = 0},})
+{x =-1, y = 0, z = 0}})
-function insulated_wire_get_rules(param2)
+function insulated_wire_get_rules(node)
+ local rules = {{x = 1, y = 0, z = 0},
+ {x =-1, y = 0, z = 0}}
if param2 == 1 or param2 == 3 then
- return mesecon:rotate_rules_right(mesecon:get_rules("insulated"))
+ return mesecon:rotate_rules_right(rules)
end
- return mesecon:get_rules("insulated")
+ return rules
end
-
-mesecon:register_conductor("mesecons_insulated:insulated_on", "mesecons_insulated:insulated_off", mesecon:get_rules("insulated_all"), insulated_wire_get_rules)
diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua
index 49edb48..f7a2edd 100644
--- a/mesecons_pressureplates/init.lua
+++ b/mesecons_pressureplates/init.lua
@@ -150,23 +150,6 @@ minetest.register_craft({
}
})
-mesecon:add_rules("pressureplate",
-{{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: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"))