diff --git a/html/englishEN.html b/html/englishEN.html index 48dfc31..89d39d7 100644 --- a/html/englishEN.html +++ b/html/englishEN.html @@ -30,8 +30,14 @@

Part Two: ABMs

+ +

Part Three: Lua Files and Debuging

+ @@ -122,8 +128,8 @@ To do this on Windows, use WordPad.
Click file>save as, dropdown to all fil
3) Next make another sub folder called 'textures'. This is where you will place the textures
-

Tutorial 1: Decowood

-

Chapter 2: [tutorial] Your first mod!

+

Part One: Declaring and Crafting Nodes

+

Chapter 2: Defining a node

We are going to make a mod that adds a special kind of wood that can only be used for decoration.
For this, create a new mod called 'tutorial' using the method described in Chapter 0. @@ -213,8 +219,8 @@ In this case The crafting recipe is like this:

The
 </p>
 
 Easy, isn't it? You may also try out some other combinations!<br />
-
-<p>So what is 'default'? 'default' is the most important What is the mod "default"? +

So what is default? 'default' is the most important "mod" of minetest, in fact minetest itself is more like just a game engine, all the contents, materials, and other stuff are in several mods, like 'default' (standard tools/blocks), 'bucket' (Buckets: Lava/Water),...

If you want to find out more about these mods and maybe use features they contain, just have a look in their init.lua!
@@ -292,7 +298,7 @@ minetest.register_abm(

You should already know everything else but the line "pos.y=pos.y+1".

-

Chapter 5: The Position Variable

+

The Position Variable

To understand the position variable, you need to know that in 3d space, positions are determind by three co-ordinates: x,y,z
@@ -304,6 +310,110 @@ The player usually spawns near 0,0,0.
The interval is 1 in this case, but the chance (probability) is 100.Therefore the function is executed every second, but only in 1 of 100 cases.
This makes your minetest garden slowly been overgrown by junglegrass. +

Part Three - Lua Files and Debugging

+

Chapter # - Including Files

+

The dofile function

+Sometimes you have so much code, a single init.lua file is too hard to maintain. + +

+But there is a solution! dofile(minetest.get_modpath("chess").."/anotherfile.lua") will tell Minetest to look for anotherfile.lua in the same folder as init.lua, and add load its contents. +

+

Chapter # - Debugging

+

Types of errors and Bugs

+As with most programming, when you develop you tend to get what are called "bugs" and errors, which are basically human mistakes.
+There are three types of bugs/errors +

+ +

Avoiding Syntax Mistakes

+To help avoid syntax mistakes, make sure your code is easy to read. + +

+ + +
+Which one of these codes is easier to read? +

+

+minetest.register_abm(
+	{nodenames = {"default:dirt_with_grass"},
+	interval = 1,
+	chance = 100,
+	action = function(pos)
+		pos.y=pos.y+1
+		minetest.env:add_node(pos, {name="default:junglegrass"})
+	end,
+})
+
+

+

+

+minetest.register_abm({nodenames = {"default:dirt_with_grass"},interval = 1,chance = 100,
+action = function(pos)
+pos.y=pos.y+1
+minetest.env:add_node(pos, {name="default:junglegrass"})
+end,
+})
+
+

+
+

+Also you should check your work and put comments in +

+ +pos.y=pos.y+1 --This line increases the position's y axis by 1 + +

+ +

Avoiding Runtime Mistakes

+ + + +

+The Console is the black window with writing in that appears when Minetest runs.

+
+ + +

LUA has a function called "print" and it displays a message to the console.

+ +

+ +print("message to send") + +

+ +You should the print function so you know how far Minetest gets in a program.
+

+ + +
Why use print
+For example, you have a mistake in the code: + +

+ +

+check_something(1)
+
+function check_something(value)
+
+if value=0 then
+   print("it ends up here")
+else
+    print("but you are certern that value=1")
+end
+
+end
+
+ +

+ +The aboves Runtime bug was caused by a single "=" instead of double "==", and so instead of checking if value was equal to 0, it set it to 0 resulting in true
+And so having print helps point out your mistake. +
+

Apendix

Learn to code

diff --git a/html/stylesheet.css b/html/stylesheet.css index 015c0f0..a1c5111 100644 --- a/html/stylesheet.css +++ b/html/stylesheet.css @@ -20,7 +20,7 @@ text-decoration:underline; h3 { -color:black; +color:0000BB; text-align:left; font-size:12pt; }