Node Timers and ABMs: Add note on return true in on_timer

master
rubenwardy 2018-11-14 15:09:43 +00:00
parent cea9940037
commit 6465c125c8
1 changed files with 19 additions and 12 deletions

View File

@ -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