Lua Tutorial [First Attempt]

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

Lua Tutorial [First Attempt]

by Jeija » Tue Feb 21, 2012 06:55

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
Last edited by Jeija on Fri Oct 05, 2012 19:00, edited 1 time in total.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
IPushButton2653
Member
 
Posts: 666
Joined: Wed Nov 16, 2011 22:47

by IPushButton2653 » Tue Feb 21, 2012 23:31

Finally something useful :D
 

User avatar
Death Dealer
Member
 
Posts: 1379
Joined: Wed Feb 15, 2012 18:46

by Death Dealer » Wed Feb 22, 2012 07:43

thanks man really helped.
Keep calm and code python^_^
 

User avatar
Lippis
Member
 
Posts: 65
Joined: Mon Feb 13, 2012 18:50

by Lippis » Wed Feb 22, 2012 08:06

Thanks a lot!
Started LUA coding again :P
 

Gatharoth
Member
 
Posts: 196
Joined: Thu Dec 22, 2011 02:54

by Gatharoth » Wed Feb 22, 2012 20:06

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.
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Wed Feb 22, 2012 20:31

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.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Mon Mar 05, 2012 03:09

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
:)
If you can think it, you can make it.
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Mon Mar 05, 2012 11:55

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)
Redstone for minetest: Mesecons (mesecons.net)
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Sat Mar 10, 2012 08:58

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? :)
:D
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sat Mar 10, 2012 09:05

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
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
JoseMing
Member
 
Posts: 107
Joined: Tue Feb 21, 2012 00:01

by JoseMing » Tue Apr 03, 2012 15:52

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"?
Nothing is impossible, Only you need you mind to create... and Sorry for my Bad English :D
Add me on remobo as JoseGarcia
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Tue Apr 03, 2012 15:56

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.
:D
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Tue Apr 03, 2012 16:19

Gedit is a good one, better than leafpad, mousepad, and windows notepad
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Tue Apr 03, 2012 16:59

Geany is good
Image
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Tue Apr 03, 2012 17:02

sfan5 wrote:Geany is good
Image

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

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33

by sdzen » Tue Apr 03, 2012 19:49

tell me has this been updated yet? last i looked it about it wasnt
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Tue Apr 03, 2012 19:50

It has not been updated.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45

by redcrab » Tue Apr 03, 2012 21:51

Thanks for this documentation ... "Two thumbs up"
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Aug 20, 2012 18:28

Hope my update was helpfull...
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Aug 20, 2012 21:27

I have done the html version of the english one.

http://tinyurl.com/mt-tut


It has been pull-requested
Last edited by rubenwardy on Tue Aug 21, 2012 00:58, edited 1 time in total.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Aug 22, 2012 06:32

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.
 

User avatar
tonyka
Member
 
Posts: 320
Joined: Sat Jun 16, 2012 04:08

by tonyka » Wed Aug 22, 2012 08:00

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...
My mod: [MOD]3D Forniture 1.0
Download: 3DForniture_v_1.0.zip
Page development (European Castilian):
Moviliario 3D (proyecto 3D Forniture)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Wed Aug 22, 2012 10:05

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
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Wed Aug 22, 2012 12:16

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.
Last edited by Calinou on Wed Aug 22, 2012 12:18, edited 1 time in total.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Wed Aug 22, 2012 15:10

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. :)

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
tonyka
Member
 
Posts: 320
Joined: Sat Jun 16, 2012 04:08

by tonyka » Wed Aug 22, 2012 22:00

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...
Last edited by tonyka on Wed Aug 22, 2012 22:09, edited 1 time in total.
My mod: [MOD]3D Forniture 1.0
Download: 3DForniture_v_1.0.zip
Page development (European Castilian):
Moviliario 3D (proyecto 3D Forniture)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri Oct 05, 2012 17:27

Can you put a link to my published version, http://tinyurl.com/mt-tut ?
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Fri Oct 05, 2012 19:02

done
Redstone for minetest: Mesecons (mesecons.net)
 

davegoopot
Member
 
Posts: 15
Joined: Sat Apr 06, 2013 08:43
GitHub: davegoopot

by davegoopot » Sat Apr 06, 2013 08:58

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.
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Sat Apr 06, 2013 09:13

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
Redstone for minetest: Mesecons (mesecons.net)
 

Next

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 13 guests