summaryrefslogtreecommitdiff
path: root/node_controllers.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-08 01:23:10 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-08 01:23:10 -0700
commitd7e5309833bc7044447982424dc8431d84d7a1a0 (patch)
treedb1081d61fd650db0593ef190b0bb32f93a19b3a /node_controllers.lua
parente704249735372a3232883cc8b7f25679f4949a8d (diff)
Added a rotation controller
Well that was a lot of work. Also, switched the "waiting" timer management to the actual on_timer system - I noticed that minetest.after wasn't persisting through server shutdown and restart, that could put a controller in a "broken" state.
Diffstat (limited to 'node_controllers.lua')
-rw-r--r--node_controllers.lua32
1 files changed, 17 insertions, 15 deletions
diff --git a/node_controllers.lua b/node_controllers.lua
index 323b8f2..7dc1e7f 100644
--- a/node_controllers.lua
+++ b/node_controllers.lua
@@ -58,11 +58,11 @@ minetest.register_node("digtron:controller", {
-- Start the delay before digtron can run again.
minetest.get_meta(newpos):set_string("waiting", "true")
- minetest.after(digtron.cycle_time,
- function (pos)
- minetest.get_meta(pos):set_string("waiting", nil)
- end, newpos
- )
+ minetest.get_node_timer(newpos):start(digtron.cycle_time)
+ end,
+
+ on_timer = function(pos, elapsed)
+ minetest.get_meta(pos):set_string("waiting", nil)
end,
})
@@ -180,6 +180,11 @@ minetest.register_node("digtron:auto_controller", {
meta:set_string("waiting", "true")
meta:set_string("formspec", auto_formspec)
end,
+
+ on_timer = function(pos, elapsed)
+ minetest.get_meta(pos):set_string("waiting", nil)
+ end,
+
})
---------------------------------------------------------------------------------------------------------------
@@ -250,11 +255,7 @@ minetest.register_node("digtron:pusher", {
if not can_move then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds
meta:set_string("waiting", "true")
- minetest.after(digtron.cycle_time,
- function (pos)
- minetest.get_meta(pos):set_string("waiting", nil)
- end, pos
- )
+ minetest.get_node_timer(pos):start(digtron.cycle_time)
minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron is obstructed.")
@@ -283,10 +284,11 @@ minetest.register_node("digtron:pusher", {
-- Start the delay before digtron can run again. Do this after moving the array or pos will be wrong.
minetest.get_meta(pos):set_string("waiting", "true")
- minetest.after(digtron.cycle_time,
- function (pos)
- minetest.get_meta(pos):set_string("waiting", nil)
- end, pos
- )
+ minetest.get_node_timer(pos):start(digtron.cycle_time)
+ end,
+
+ on_timer = function(pos, elapsed)
+ minetest.get_meta(pos):set_string("waiting", nil)
end,
+
}) \ No newline at end of file