From 6465c125c8fc4235b70973a1c8408109cfeb957f Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 14 Nov 2018 15:09:43 +0000 Subject: [PATCH] Node Timers and ABMs: Add note on return true in on_timer --- _en/map/timers.md | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/_en/map/timers.md b/_en/map/timers.md index 2b2a079..f78c201 100644 --- a/_en/map/timers.md +++ b/_en/map/timers.md @@ -34,18 +34,6 @@ of pending timers. ## Node Timers Node timers are directly tied to a single node. -When a node timer is up, the `on_timer` method in the node's definition table will -be called. -The method only takes a single parameter, the position of the node. - -```lua -minetest.register_node("autodoors:door_open", { - on_timer = function(pos) - minetest.set_node(pos, { name = "autodoors:door" }) - end -}) -``` - You can manage node timers by obtaining a NodeTimerRef object. ```lua @@ -64,6 +52,25 @@ end timer:stop() ``` +When a node timer is up, the `on_timer` method in the node's definition table will +be called. +The method only takes a single parameter, the position of the node. + +```lua +minetest.register_node("autodoors:door_open", { + on_timer = function(pos) + minetest.set_node(pos, { name = "autodoors:door" }) + return false + end +}) +``` + +Returning true in `on_timer` will cause the timer to run again for the same interval. + +You may have noticed a limitation with timers: for optimisation reasons, it's +only possible to have one type of timer per node type, and only one timer running per node. + + ## Active Block Modifiers Alien grass, for the purposes of this chapter, is a type of grass which