summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons/settings.lua1
-rw-r--r--mesecons_pressureplates/init.lua116
2 files changed, 59 insertions, 58 deletions
diff --git a/mesecons/settings.lua b/mesecons/settings.lua
index 103c62a..db084c6 100644
--- a/mesecons/settings.lua
+++ b/mesecons/settings.lua
@@ -1,3 +1,4 @@
-- SETTINGS
BLINKY_PLANT_INTERVAL = 3
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
+PRESSURE_PLATE_INTERVAL = 0.1
diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua
index cd96be3..49edb48 100644
--- a/mesecons_pressureplates/init.lua
+++ b/mesecons_pressureplates/init.lua
@@ -18,6 +18,22 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2},
description="Wood Pressure Plate",
+
+ on_timer = function(pos, elapsed)
+ local objs = minetest.env:get_objects_inside_radius(pos, 1)
+ for k, obj in pairs(objs) do
+ 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"))
+ end
+ end
+ return true
+ end,
+
+ on_construct = function(pos)
+ minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
+ end,
})
minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
@@ -36,6 +52,19 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_pressureplates:pressure_plate_wood_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_wood_off"})
+ mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
+ end
+ return true
+ end,
+
+ on_construct = function(pos)
+ minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
+ end,
})
minetest.register_craft({
@@ -45,35 +74,6 @@ minetest.register_craft({
}
})
-minetest.register_abm(
- {nodenames = {"mesecons_pressureplates:pressure_plate_wood_off"},
- 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, 1)
- for k, obj in pairs(objs) do
- 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"))
- end
- end
- end,
-})
-
-minetest.register_abm(
- {nodenames = {"mesecons_pressureplates:pressure_plate_wood_on"},
- 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, 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"))
- end
- end,
-})
-
-- PRESSURE PLATE STONE
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
@@ -94,6 +94,22 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2},
description="Stone Pressure Plate",
+
+ on_timer = function(pos, elapsed)
+ local objs = minetest.env:get_objects_inside_radius(pos, 1)
+ for k, obj in pairs(objs) do
+ 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"))
+ end
+ end
+ return true
+ end,
+
+ on_construct = function(pos)
+ minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
+ end,
})
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
@@ -112,6 +128,19 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
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"))
+ end
+ return true
+ end,
+
+ on_construct = function(pos)
+ minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
+ end,
})
minetest.register_craft({
@@ -121,35 +150,6 @@ minetest.register_craft({
}
})
-minetest.register_abm(
- {nodenames = {"mesecons_pressureplates:pressure_plate_stone_off"},
- 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, 1)
- for k, obj in pairs(objs) do
- 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"))
- end
- end
- end,
-})
-
-minetest.register_abm(
- {nodenames = {"mesecons_pressureplates:pressure_plate_stone_on"},
- 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, 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"))
- end
- end,
-})
-
mesecon:add_rules("pressureplate",
{{x=0, y=1, z=-1},
{x=0, y=0, z=-1},