Active Block Modifiers: Improve grammar, and clarify some points

master
Ezhh 2017-08-29 00:21:46 +01:00 committed by rubenwardy
parent 136dde885a
commit ee10fcd6fd
1 changed files with 17 additions and 13 deletions

View File

@ -6,20 +6,19 @@ root: ../../
## Introduction
In this chapter we will learn how to create an **A**ctive **B**lock **M**odifier (**ABM**).
An active block modifier allows you to run code on certain nodes at certain
intervals.
Please be warned, ABMs which are too frequent or act on too many nodes cause
massive amounts of lag. Use them lightly.
An active *A**ctive **B**lock **M**odifier (**ABM**) allows you to run code on
certain nodes at specific intervals.
Please be warned, ABMs which are too frequent or act on a large number of nodes
cause massive amounts of lag. Use them sparingly.
* Special Growing Grass
* Your Turn
## Special Growing Grass
We are now going to make a mod (yay!).
It will add a type of grass called alien grass - it grows near water on grassy
blocks.
If you want to make a mod that adds a type of grass called alien grass
- it grows near water on grassy blocks - you first register the grass, then
write an ABM.
{% highlight lua %}
minetest.register_node("aliens:grass", {
@ -41,12 +40,17 @@ minetest.register_abm({
})
{% endhighlight %}
Every ten seconds the ABM is run. Each node which has the correct nodename and
the correct neighbors then has a 1 in 5 chance of being run. If a node is run on,
an alien grass block is placed above it. Please be warned, that will delete any
blocks above grass blocks - you should check there is space by doing minetest.get_node.
This ABM runs every ten seconds. There is a 1 in 5 chance of the ABM running on each
node that has the correct name and the correct neighbors. If the ABM runs on a
node, an alien grass node is placed above it. Please be warned, this will delete any
node previously located in that position. To prevent this you should include a check
using minetest.get_node to make sure there is space for the grass.
That's really all there is to ABMs. Specifying a neighbor is optional, so is chance.
Specifying a neighbor is optional. If you specify multiple neighbors, only one of them
needs to be present to meet the requirements.
Specifying chance is also optional. If you don't specify the chance, the ABM will
always run when the other conditions are met.
## Your Turn