summaryrefslogtreecommitdiff
path: root/mesecons_pressureplates
diff options
context:
space:
mode:
authorJeija <norrepli@googlemail.com>2012-12-07 12:51:44 -0800
committerJeija <norrepli@googlemail.com>2012-12-07 12:51:44 -0800
commit3926c46293e1ecafcc79bfef080f6b4fae20f0da (patch)
tree633b6e94e8e1bb3266f7b569ca56afe061ab17c0 /mesecons_pressureplates
parent7542dd4da088ddadfb4a4e9a0a93a16e35f11469 (diff)
parent4a8e20b68ee26b13866c856730f745beb676021c (diff)
downloadmesecons-3926c46293e1ecafcc79bfef080f6b4fae20f0da.tar
mesecons-3926c46293e1ecafcc79bfef080f6b4fae20f0da.tar.gz
mesecons-3926c46293e1ecafcc79bfef080f6b4fae20f0da.tar.bz2
mesecons-3926c46293e1ecafcc79bfef080f6b4fae20f0da.tar.xz
mesecons-3926c46293e1ecafcc79bfef080f6b4fae20f0da.zip
Merge pull request #58 from PilzAdam/master
Speed update of pressureplates up by using node_timers
Diffstat (limited to 'mesecons_pressureplates')
-rw-r--r--mesecons_pressureplates/init.lua116
1 files changed, 58 insertions, 58 deletions
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},