Active Block Modifiers: Improve grammar, and clarify some points
This commit is contained in:
parent
136dde885a
commit
ee10fcd6fd
@ -6,20 +6,19 @@ root: ../../
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
In this chapter we will learn how to create an **A**ctive **B**lock **M**odifier (**ABM**).
|
An active *A**ctive **B**lock **M**odifier (**ABM**) allows you to run code on
|
||||||
An active block modifier allows you to run code on certain nodes at certain
|
certain nodes at specific intervals.
|
||||||
intervals.
|
Please be warned, ABMs which are too frequent or act on a large number of nodes
|
||||||
Please be warned, ABMs which are too frequent or act on too many nodes cause
|
cause massive amounts of lag. Use them sparingly.
|
||||||
massive amounts of lag. Use them lightly.
|
|
||||||
|
|
||||||
* Special Growing Grass
|
* Special Growing Grass
|
||||||
* Your Turn
|
* Your Turn
|
||||||
|
|
||||||
## Special Growing Grass
|
## Special Growing Grass
|
||||||
|
|
||||||
We are now going to make a mod (yay!).
|
If you want to make a mod that adds a type of grass called alien grass
|
||||||
It will add a type of grass called alien grass - it grows near water on grassy
|
- it grows near water on grassy blocks - you first register the grass, then
|
||||||
blocks.
|
write an ABM.
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
minetest.register_node("aliens:grass", {
|
minetest.register_node("aliens:grass", {
|
||||||
@ -41,12 +40,17 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Every ten seconds the ABM is run. Each node which has the correct nodename and
|
This ABM runs every ten seconds. There is a 1 in 5 chance of the ABM running on each
|
||||||
the correct neighbors then has a 1 in 5 chance of being run. If a node is run on,
|
node that has the correct name and the correct neighbors. If the ABM runs on a
|
||||||
an alien grass block is placed above it. Please be warned, that will delete any
|
node, an alien grass node is placed above it. Please be warned, this will delete any
|
||||||
blocks above grass blocks - you should check there is space by doing minetest.get_node.
|
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
|
## Your Turn
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user