Page 1 of 2

Lua Tutorial [First Attempt]

PostPosted: Tue Feb 21, 2012 06:55
by Jeija
Hello everyone!

I wrote the first few chapters of a modding tutorial for minetest. I put it on GitHub so that others can help by fixing my tons of mistakes and writing more.

I have made a German version (also with HTML) and an English version (txt only).
I am not gonna continue the German one, maybe someone else wants to do that.

Would be nice if some people tested it (Is it easy to understand, structured?)

Please help making this tutorial better so that more people can learn how to create mods!

Download
GitHub Repo
As .zip
As .tar.gz

View Online
http://multa.bugs3.com/minetest/tutorial/

This modding tutorial has been created for an open-source writing competition
Dieses Tutorial wurde im Rahmen eines Open-Source Schreibwettbewerbs erstellt

PostPosted: Tue Feb 21, 2012 23:31
by IPushButton2653
Finally something useful :D

PostPosted: Wed Feb 22, 2012 07:43
by Death Dealer
thanks man really helped.

PostPosted: Wed Feb 22, 2012 08:06
by Lippis
Thanks a lot!

PostPosted: Wed Feb 22, 2012 20:06
by Gatharoth
Alright, this is great, but few things I noticed.

  • No Chapter 3
  • In "Chapter 4" you have the line of code "chance = 100". Which to some people would be confused by it. So maybe reference what it does again.

While those that will actually read everything will understand that it will be changed to "1:100". But as someone new to modding, would be slightly confused by it.

Alright aside from that. It looks great, easy to understand. However I do not really think that the requirements are needed. I think that the explanation of the first ABM so be more separated. So same thing you have already, but break it up. Something like this.

Try it out! It's really annoying to see all your decowood creations destroyed after 30 seconds, they simple become normal wood.

But how does this work?
The function minetest.register_abm registers an action for each block of the same type.

nodenames = {"tutorial:decowood'} means that the action is processed for each decowood block.

You could also try "default:stone" instead of that to turn all stone blocks into wood.

interval = 30 means that the action is performed every 30 seconds. It starts counting at the beginning of the game. After 30 seconds all actions are processed, it doesn't matter when the block was placed.

This is not a per-block timer!

chance = 1 means that the probability of the action is 1:1, it happens in every case.
A higher value means that it's less probable.

action = function(pos) is the function that is actually performed.

It contains the command minetest.env:add_node. This takes two parameters:

First of all the position parameter (more information later) and also a table which defines the properties of the block, e.g. the name, the direction it faces, ...
In this case the name is enough to define what block you can see.


This makes it a bit easier on the eyes since it is split up. Also allows the reader to follow what you are saying easier. It is not just a "wall of text"

note: words in bold are spelling corrections.

PostPosted: Wed Feb 22, 2012 20:31
by Jeija
No Chapter 3

Yeah you're right. Let's say it's invisible [changed 4 to 3]
In "Chapter 4" you have the line of code "chance = 100". Which to some people would be confused by it. So maybe reference what it does again.

I think this is enough:
There are some small other differences to our first abm. 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.

I also splitted up the whole thing a little.
Thanks for your contribution! I may also add you or someone else on GitHub so it's easier to contribute.

PostPosted: Mon Mar 05, 2012 03:09
by jordan4ibanez
for the love of everything please continue this jeija
heres some things i would REALLY love to see:
-explain how to create files through lua
-english
:)

PostPosted: Mon Mar 05, 2012 11:55
by Jeija
The whole tutorial is in english, but only as plain text file.
I think for creating files through lua, you can use other general lua tutorials. Just google it!

e.g. lua io.open (thats the command for creating/opening files)

PostPosted: Sat Mar 10, 2012 08:58
by cosarara97
Thanks!
I found an error:
Line 49:
Crafting does not only play an important role in minecraft, also minetest uses different crafting recipes

Shouldn't both be minetest? :)

PostPosted: Sat Mar 10, 2012 09:05
by sfan5
cosarara97 wrote:Thanks!
I found an error:
Line 49:
Crafting does not only play an important role in minecraft, also minetest uses different crafting recipes

Shouldn't both be minetest? :)

Nope, Crafting is important in Minecraft and Minetest

PostPosted: Tue Apr 03, 2012 15:52
by JoseMing
Jeija wrote:Hello everyone!

I wrote the first few chapters of a modding tutorial for minetest. I put it on GitHub so that others can help by fixing my tons of mistakes and writing more.

I have made a German version (also with HTML) and an English version (txt only).
I am not gonna continue the German one, maybe someone else wants to do that.

Would be nice if some people tested it (Is it easy to understand, structured?)

Please help making this tutorial better so that more people can learn how to create mods!

Download
GitHub Repo
As .zip
As .tar.gz

This modding tutorial has been created for an open-source writing competition
Dieses Tutorial wurde im Rahmen eines Open-Source Schreibwettbewerbs erstellt

jeija, what you need to make a "init.lua"?

PostPosted: Tue Apr 03, 2012 15:56
by cosarara97
JoseMing wrote:
Jeija wrote:Hello everyone!

I wrote the first few chapters of a modding tutorial for minetest. I put it on GitHub so that others can help by fixing my tons of mistakes and writing more.

I have made a German version (also with HTML) and an English version (txt only).
I am not gonna continue the German one, maybe someone else wants to do that.

Would be nice if some people tested it (Is it easy to understand, structured?)

Please help making this tutorial better so that more people can learn how to create mods!

Download
GitHub Repo
As .zip
As .tar.gz

This modding tutorial has been created for an open-source writing competition
Dieses Tutorial wurde im Rahmen eines Open-Source Schreibwettbewerbs erstellt

jeija, what you need to make a "init.lua"?

A plain text editor. I use gedit.

PostPosted: Tue Apr 03, 2012 16:19
by bgsmithjr
Gedit is a good one, better than leafpad, mousepad, and windows notepad

PostPosted: Tue Apr 03, 2012 16:59
by sfan5
Geany is good
Image

PostPosted: Tue Apr 03, 2012 17:02
by Jordach
sfan5 wrote:Geany is good
Image

I agree with you Sfan. This program really works for me on Linux Mint.

PostPosted: Tue Apr 03, 2012 19:49
by sdzen
tell me has this been updated yet? last i looked it about it wasnt

PostPosted: Tue Apr 03, 2012 19:50
by Jeija
It has not been updated.

PostPosted: Tue Apr 03, 2012 21:51
by redcrab
Thanks for this documentation ... "Two thumbs up"

PostPosted: Mon Aug 20, 2012 18:28
by rubenwardy
Hope my update was helpfull...

PostPosted: Mon Aug 20, 2012 21:27
by rubenwardy
I have done the html version of the english one.

http://tinyurl.com/mt-tut


It has been pull-requested

PostPosted: Wed Aug 22, 2012 06:32
by cornernote
awesome work!

1 thing i noticed.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
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.


You should change chess to tutorial.

PostPosted: Wed Aug 22, 2012 08:00
by tonyka
sfan5 wrote:Geany is good
Image

Geany is the best in linux
Bluefish is also very good, but this is designed for web development, also has support for Lua...

PostPosted: Wed Aug 22, 2012 10:05
by rubenwardy
cornernote wrote:awesome work!

1 thing i noticed.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
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.


You should change chess to tutorial.


Thank you, i will correct that

PostPosted: Wed Aug 22, 2012 12:16
by Calinou
tonyka wrote:Geany is the best in linux
Bluefish is also very good, but this is designed for web development, also has support for Lua...


Personally I use Mousepad - (Xfce's [too simple] text editor, and there doesn't seem to be any better solution for Xfce); gedit is a GNOME application, so it doesn't work well... I'm not a fan of text-based editors too.

PostPosted: Wed Aug 22, 2012 15:10
by Jordach
Calinou wrote:
tonyka wrote:Geany is the best in linux
Bluefish is also very good, but this is designed for web development, also has support for Lua...


Personally I use Mousepad - (Xfce's [too simple] text editor, and there doesn't seem to be any better solution for Xfce); gedit is a GNOME application, so it doesn't work well... I'm not a fan of text-based editors too.

Gedit works fine in XFCE.

Tried and tested. :)

PostPosted: Wed Aug 22, 2012 22:00
by tonyka
Jordach wrote:
Calinou wrote:
tonyka wrote:Geany is the best in linux
Bluefish is also very good, but this is designed for web development, also has support for Lua...


Personally I use Mousepad - (Xfce's [too simple] text editor, and there doesn't seem to be any better solution for Xfce); gedit is a GNOME application, so it doesn't work well... I'm not a fan of text-based editors too.

Gedit works fine in XFCE.

Tried and tested. :)


if & not, Calinou is right, Xfce comes with devian distributed, but can also be used with gnome, you're probably using a gnome distro like Xubuntu (Xfce desktop + Ubuntu)... devian gedit works in, but not just as in gnome...
I personally use the LXDE desktop, is somewhat less light, but for my niece looks more like Windows...

PostPosted: Fri Oct 05, 2012 17:27
by rubenwardy
Can you put a link to my published version, http://tinyurl.com/mt-tut ?

PostPosted: Fri Oct 05, 2012 19:02
by Jeija
done

PostPosted: Sat Apr 06, 2013 08:58
by davegoopot
Hi,

I'm looking to use Minetest as an introduction to Lua programming tutorial for a local kids programming group. From a quick look this tutorial seems to be a great starting point. Is it still up-to-date enough with the current Minetest release (0.4.6 at the time of writing)?

Thanks,

Dave.

PostPosted: Sat Apr 06, 2013 09:13
by Jeija
Hi!

Minetest programming really is a great, easy and fun introduction to Lua Programming. This tutorial should still work, but is incomplete as tons of more features have been added.
It was reworked and published at at the Minetest API page. That page should always contain latest information about the Lua API. For further reference, take a look at doc/lua_api.txt in the download package.
I'm sort of interested the idea of teaching kids programming using minetest... Could you report how it works out once you tried?

Jeija