Fix typos
This commit is contained in:
parent
706d74427e
commit
de4f083a5b
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
- hr: true
|
- hr: true
|
||||||
|
|
||||||
- title: Nodes, Items and Crafting
|
- title: Nodes, Items, and Crafting
|
||||||
num: 3
|
num: 3
|
||||||
link: chapters/nodes_items_crafting.html
|
link: chapters/nodes_items_crafting.html
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ This is an essential skill when creating mods.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Each mod has its own folder, where all its Lua code, textures, models and sounds
|
Each mod has its own folder where all its Lua code, textures, models, and sounds
|
||||||
are placed. These folders need to be placed in a mod location, such as
|
are placed. These folders need to be placed in a mod location such as
|
||||||
minetest/mods. Mods can be grouped into mod packs, which are explained below.
|
minetest/mods. Mods can be grouped into mod packs which are explained below.
|
||||||
|
|
||||||
A "mod name" is used to refer to a mod. Each mod should have a unique mod name,
|
A "mod name" is used to refer to a mod. Each mod should have a unique mod name,
|
||||||
which you can choose - a good mod name can describes what the mod does.
|
which you can choose - a good mod name describes what the mod does.
|
||||||
Mod names can be make up of letters, numbers or underscores. The folder a mod is
|
Mod names can be made up of letters, numbers, or underscores. The folder a mod is
|
||||||
in needs to be called the same as the mod name.
|
in needs to be called the same as the mod name.
|
||||||
|
|
||||||
### Mod Folder Structure
|
### Mod Folder Structure
|
||||||
@ -35,12 +35,12 @@ in needs to be called the same as the mod name.
|
|||||||
- (optional) models/ - place 3d models in here
|
- (optional) models/ - place 3d models in here
|
||||||
...and any other lua files to be included by init.lua
|
...and any other lua files to be included by init.lua
|
||||||
|
|
||||||
Only the init.lua file is required in a mod for it to run on game load, however
|
Only the init.lua file is required in a mod for it to run on game load; however,
|
||||||
the other items are needed by some mods to perform their functionality.
|
the other items are needed by some mods to perform their functionality.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
The depends text file allows you to specify what mods this mod requires to run, and what
|
The depends text file allows you to specify which mods this mod requires to run and what
|
||||||
needs to be loaded before this mod.
|
needs to be loaded before this mod.
|
||||||
|
|
||||||
**depends.txt**
|
**depends.txt**
|
||||||
@ -54,12 +54,12 @@ As you can see, each modname is on its own line.
|
|||||||
Mod names with a question mark following them are optional dependencies.
|
Mod names with a question mark following them are optional dependencies.
|
||||||
If an optional dependency is installed, it is loaded before the mod.
|
If an optional dependency is installed, it is loaded before the mod.
|
||||||
However, if the dependency is not installed, the mod still loads.
|
However, if the dependency is not installed, the mod still loads.
|
||||||
This is in contrast to normal dependencies, which will cause the current
|
This is in contrast to normal dependencies which will cause the current
|
||||||
mod not to work if the dependency is not installed.
|
mod not to work if the dependency is not installed.
|
||||||
|
|
||||||
## Mod Packs
|
## Mod Packs
|
||||||
|
|
||||||
Modpacks allow multiple mods to be packaged together, and move together.
|
Modpacks allow multiple mods to be packaged together and be moved together.
|
||||||
They are useful if you want to supply multiple mods to a player but don't
|
They are useful if you want to supply multiple mods to a player but don't
|
||||||
want to make them download each one individually.
|
want to make them download each one individually.
|
||||||
|
|
||||||
@ -106,5 +106,5 @@ minetest.register_node("mymod:node", {
|
|||||||
|
|
||||||
Our mod has a name of "mymod". It has two text files: init.lua and depends.txt.\\
|
Our mod has a name of "mymod". It has two text files: init.lua and depends.txt.\\
|
||||||
The script prints a message and then registers a node – which will be explained in the next chapter.\\
|
The script prints a message and then registers a node – which will be explained in the next chapter.\\
|
||||||
The depends text file adds a dependency to the default mod, which is in minetest_game.\\
|
The depends text file adds a dependency to the default mod which is in minetest_game.\\
|
||||||
There is also a texture in textures/ for the node.
|
There is also a texture in textures/ for the node.
|
||||||
|
@ -40,7 +40,7 @@ function ctf.post(team,msg)
|
|||||||
end
|
end
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
For example, keywords in the above snippet are highlighted, such as if, then, end, return.
|
For example, keywords in the above snippet are highlighted such as if, then, end, return.
|
||||||
table.insert is a function which comes with Lua by default.
|
table.insert is a function which comes with Lua by default.
|
||||||
|
|
||||||
### Recommended Editors
|
### Recommended Editors
|
||||||
@ -93,11 +93,11 @@ a = a + 10
|
|||||||
print("Sum is "..result)
|
print("Sum is "..result)
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Woah, what happened there? a, b and result are **variables**. They're like what
|
Woah, what happened there? a, b, and result are **variables**. They're like what
|
||||||
you get in mathematics, A = w * h. The equals signs are **assignments**, so
|
you get in mathematics, A = w * h. The equals signs are **assignments**, so
|
||||||
"result" is set to a + b. Variable names can be longer than one character
|
"result" is set to a + b. Variable names can be longer than one character
|
||||||
unlike in maths, as seen with the "result" variable. Lua is **case sensitive**.
|
unlike in mathematics, as seen with the "result" variable. Lua is **case sensitive**.
|
||||||
A is a different variable to a.
|
A is a different variable than a.
|
||||||
|
|
||||||
The word "local" before they are first used means that they have local scope,
|
The word "local" before they are first used means that they have local scope,
|
||||||
I'll discuss that shortly.
|
I'll discuss that shortly.
|
||||||
@ -189,8 +189,8 @@ end
|
|||||||
Programming is the action of talking a problem, such as sorting a list
|
Programming is the action of talking a problem, such as sorting a list
|
||||||
of items, and then turning it into steps that a computer can understand.
|
of items, and then turning it into steps that a computer can understand.
|
||||||
|
|
||||||
Teaching you the logical process of programming is beyond the scope of this book,
|
Teaching you the logical process of programming is beyond the scope of this book;
|
||||||
however the following websites are quite useful in developing this:
|
however, the following websites are quite useful in developing this:
|
||||||
|
|
||||||
### Codecademy
|
### Codecademy
|
||||||
[Codecademy](http://www.codecademy.com/) is one of the best resources for learning to 'code',
|
[Codecademy](http://www.codecademy.com/) is one of the best resources for learning to 'code',
|
||||||
@ -277,8 +277,8 @@ one()
|
|||||||
two()
|
two()
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Nil means **not initalised**. The variable hasn't been assigned a variable yet,
|
Nil means **not initalised**. The variable hasn't been assigned a value yet,
|
||||||
doesn't exist or has been uninitialised (ie: set to nil)
|
doesn't exist, or has been uninitialised. (ie: set to nil)
|
||||||
|
|
||||||
The same goes for functions. Functions are variables of a special type.
|
The same goes for functions. Functions are variables of a special type.
|
||||||
You should make functions as local as much as possible,
|
You should make functions as local as much as possible,
|
||||||
@ -306,7 +306,7 @@ mymod.foo("foobar")
|
|||||||
|
|
||||||
## Including other Lua Scripts
|
## Including other Lua Scripts
|
||||||
|
|
||||||
You can include Lua scripts from your mod, or another mod like this:
|
You can include Lua scripts from your mod or another mod like this:
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
dofile(minetest.get_modpath("modname") .. "/script.lua")
|
dofile(minetest.get_modpath("modname") .. "/script.lua")
|
||||||
@ -316,5 +316,5 @@ dofile(minetest.get_modpath("modname") .. "/script.lua")
|
|||||||
You won't be able to access them from any other scripts.
|
You won't be able to access them from any other scripts.
|
||||||
|
|
||||||
As for how you divide code up into files, it doesn't matter that much.
|
As for how you divide code up into files, it doesn't matter that much.
|
||||||
The most important thing is your code is easy to read and edit.
|
The most important thing is that your code is easy to read and edit.
|
||||||
You won't need to use it for smaller projects.
|
You won't need to use it for smaller projects.
|
||||||
|
@ -77,7 +77,7 @@ minetest.register_node("mymod:diamond", {
|
|||||||
|
|
||||||
## Airlike
|
## Airlike
|
||||||
|
|
||||||
These nodes are see through, and thus have no textures.
|
These nodes are see through and thus have no textures.
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
minetest.register_node("myair:air", {
|
minetest.register_node("myair:air", {
|
||||||
@ -181,7 +181,7 @@ minetest.register_node("default:water_source", {
|
|||||||
### FlowingLiquid
|
### FlowingLiquid
|
||||||
|
|
||||||
See default:water_flowing in the default mod in minetest_game, it is mostly
|
See default:water_flowing in the default mod in minetest_game, it is mostly
|
||||||
the same as the above example
|
the same as the above example.
|
||||||
|
|
||||||
## Glasslike
|
## Glasslike
|
||||||
|
|
||||||
@ -278,9 +278,9 @@ TorchLike
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
TorchLike nodes are 2D nodes which allow you to have different textures
|
TorchLike nodes are 2D nodes which allow you to have different textures
|
||||||
depending on whether they are placed against a wall, on the floor or on the ceiling.
|
depending on whether they are placed against a wall, on the floor, or on the ceiling.
|
||||||
|
|
||||||
TorchLike nodes are not restricted to torches, you could use the for switches or other
|
TorchLike nodes are not restricted to torches, you could use them for switches or other
|
||||||
items which need to have different textures depending on where they are placed.
|
items which need to have different textures depending on where they are placed.
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
@ -353,8 +353,7 @@ create node boxes by dragging the edges, it is more visual than doing it by hand
|
|||||||
|
|
||||||
### Wallmounted Nodebox
|
### Wallmounted Nodebox
|
||||||
|
|
||||||
Sometimes you want different nodeboxes for when it is place on the floor, wall and
|
Sometimes you want different nodeboxes for when it is placed on the floor, wall, or ceiling like with torches.
|
||||||
ceiling, like with torches.
|
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
minetest.register_node("default:sign_wall", {
|
minetest.register_node("default:sign_wall", {
|
||||||
|
@ -26,8 +26,8 @@ You may use metadata to store:
|
|||||||
* progress on crafting (such as in a furnace).
|
* progress on crafting (such as in a furnace).
|
||||||
* who owns the node (such as in a locked chest).
|
* who owns the node (such as in a locked chest).
|
||||||
|
|
||||||
The node's type, light levels
|
The node's type, light levels,
|
||||||
and orientation are not stored in the metadata, but are rather part
|
and orientation are not stored in the metadata, but rather are part
|
||||||
of the data itself.
|
of the data itself.
|
||||||
|
|
||||||
Metadata is stored in a key value relationship.
|
Metadata is stored in a key value relationship.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Nodes, Items and Crafting
|
title: Nodes, Items, and Crafting
|
||||||
layout: default
|
layout: default
|
||||||
root: ../
|
root: ../
|
||||||
---
|
---
|
||||||
@ -19,15 +19,15 @@ and create craft recipes.
|
|||||||
|
|
||||||
## Item Strings
|
## Item Strings
|
||||||
|
|
||||||
Each item, whether that be a node, craftitem, tool or entity, has an item string.\\
|
Each item, whether that be a node, craftitem, tool, or entity, has an item string.\\
|
||||||
This is sometimes referred to as registered name or just name.
|
This is sometimes referred to as registered name or just name.
|
||||||
A string in programming terms is a piece of text.
|
A string in programming terms is a piece of text.
|
||||||
|
|
||||||
modname:itemname
|
modname:itemname
|
||||||
|
|
||||||
The modname is the name of the folder your mod is in.
|
The modname is the name of the folder your mod is in.
|
||||||
You may call the itemname any thing you like, however it should be relevant to
|
You may call the itemname anything you like; however, it should be relevant to
|
||||||
what the item is, and it can't already be registered.
|
what the item is and it can't already be registered.
|
||||||
|
|
||||||
### Overriding
|
### Overriding
|
||||||
|
|
||||||
@ -60,13 +60,13 @@ minetest.register_craftitem("mymod:diamond_fragments", {
|
|||||||
})
|
})
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Item definitions like seen above are usually made up of an unique
|
Item definitions like seen above are usually made up of a unique
|
||||||
[item string](#item-strings) and a definition table. The definition table
|
[item string](#item-strings) and a definition table. The definition table
|
||||||
contains attributes which affect the behaviour of the item.
|
contains attributes which affect the behaviour of the item.
|
||||||
|
|
||||||
### Foods
|
### Foods
|
||||||
|
|
||||||
Foods are items that cure health. To create a food item, you need to define the on_use property like this:
|
Foods are items that cure health. To create a food item you need to define the on_use property like this:
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
minetest.register_craftitem("mymod:mudpie", {
|
minetest.register_craftitem("mymod:mudpie", {
|
||||||
@ -77,7 +77,7 @@ minetest.register_craftitem("mymod:mudpie", {
|
|||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
The number supplied to the minetest.item_eat function is the number of hit points that are healed by this food.
|
The number supplied to the minetest.item_eat function is the number of hit points that are healed by this food.
|
||||||
Two hit points make one heart, and because there are 10 hearts there are 20 hitpoints.
|
Two hit points make one heart and because there are 10 hearts there are 20 hitpoints.
|
||||||
Hitpoints don't have to be integers (whole numbers), they can be decimals.
|
Hitpoints don't have to be integers (whole numbers), they can be decimals.
|
||||||
|
|
||||||
Sometimes you may want a food to be replaced with another item when being eaten,
|
Sometimes you may want a food to be replaced with another item when being eaten,
|
||||||
@ -125,11 +125,11 @@ mod, you should consider using minetest.register_on_item_eat
|
|||||||
## Registering a basic node
|
## Registering a basic node
|
||||||
|
|
||||||
In Minetest, a node is an item that you can place.
|
In Minetest, a node is an item that you can place.
|
||||||
Most nodes are 1m x 1m x 1m cubes, however the shape doesn't
|
Most nodes are 1m x 1m x 1m cubes; however, the shape doesn't
|
||||||
have to be a cube - as we will explore later.
|
have to be a cube - as we will explore later.
|
||||||
|
|
||||||
Let's get onto it. A node's definition table is very similar to a craftitem's
|
Let's get onto it. A node's definition table is very similar to a craftitem's
|
||||||
definition table, however you need to set the textures for the faces of the cube.
|
definition table; however, you need to set the textures for the faces of the cube.
|
||||||
|
|
||||||
{% highlight lua %}
|
{% highlight lua %}
|
||||||
minetest.register_node("mymod:diamond", {
|
minetest.register_node("mymod:diamond", {
|
||||||
@ -267,7 +267,7 @@ minetest.register_craft({
|
|||||||
|
|
||||||
As you can see from this example, the only real difference in the code
|
As you can see from this example, the only real difference in the code
|
||||||
is that the recipe is just a single item, compared to being in a table
|
is that the recipe is just a single item, compared to being in a table
|
||||||
(between braces). They also have an optional "cooktime" parameter, which
|
(between braces). They also have an optional "cooktime" parameter which
|
||||||
defines how long the item takes to cook. If this is not set it defaults to 3.
|
defines how long the item takes to cook. If this is not set it defaults to 3.
|
||||||
|
|
||||||
The recipe above works when the coal block is in the input slot,
|
The recipe above works when the coal block is in the input slot,
|
||||||
@ -288,14 +288,14 @@ minetest.register_craft({
|
|||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
They don't have an output like other recipes, but they have a burn time
|
They don't have an output like other recipes, but they have a burn time
|
||||||
which defines how long they will last as fuel, in seconds.
|
which defines how long they will last as fuel in seconds.
|
||||||
So, the diamond is good as fuel for 300 seconds!
|
So, the diamond is good as fuel for 300 seconds!
|
||||||
|
|
||||||
## Groups
|
## Groups
|
||||||
|
|
||||||
Items can be members of many groups, and groups can have many members.
|
Items can be members of many groups and groups can have many members.
|
||||||
Groups are usually identified using `group:group_name`
|
Groups are usually identified using `group:group_name`
|
||||||
There are several reason you use groups.
|
There are several reasons you use groups.
|
||||||
|
|
||||||
Groups can be used in crafting recipes to allow interchangeability
|
Groups can be used in crafting recipes to allow interchangeability
|
||||||
of ingredients. For example, you may use group:wood to allow any wood
|
of ingredients. For example, you may use group:wood to allow any wood
|
||||||
|
Loading…
x
Reference in New Issue
Block a user