Solarus-Games English Forum

Community => General discussion => Topic started by: paragonx9 on August 07, 2013, 05:08:56 AM

Title: How much experience in Lua is needed prior to starting to use Solarus?
Post by: paragonx9 on August 07, 2013, 05:08:56 AM
I have never "dived" deep into the world of programming, although I have some basic knowledge of C++. I recently watched one of the video tutorials, and in the description, it had a link to a tutorial for Lua. So, I wonder, how much / what parts of Lua should you learn before using Solarus? I know this is a weird question, considering you can't really tell someone how much programming they should know, but how long should I "study" Lua before taking a shot at making a game at Solarus?
Title: Re: How much experience in Lua is needed prior to starting to use Solarus?
Post by: Christopho on August 07, 2013, 07:38:01 AM
TL;DR
Chapters 1 to 5 of http://www.lua.org/pil/contents.html

That's a very good question.
Like always in programming, it is better not to start directly by writing code, but learning and using Lua is easy.

Lua is very minimalist but powerful. There are only a few mechanisms to learn (variables, functions, table, metatables), everything is built using these base mechanisms.

To learn Lua, the best way is to buy the Programming in Lua book (http://www.amazon.com/Programming-Third-Edition-Roberto-Ierusalimschy/dp/859037985X/ref=sr_1_1?ie=UTF8&qid=1375852750&sr=8-1&keywords=programming+in+lua) in its latest edition. It is the recommended book.

But you can also read the online version of the first edition of that book, it is free: http://www.lua.org/pil/contents.html
I recommend to read chapters 1 to 5, then you know enough to make scripts for Solarus. Later, you should also read chapters 11, 13, 16, 18, 19, 20 to understand what you are doing.

I should make a page or a PDF sheet that summarizes the main features of Lua, on the documentation or the wiki. Especially the ones that are important for Solarus:
- Variables should be declared local unless you know what you are doing.
- Functions are first-class values. The definition of a function is actually an assignment (to a variable or to a table field).
- Tables are the only data structure.
- The semicolon operator is syntaxic sugar to hide the first parameter of a function.
- A Lua script file is a regular function and can take parameters with the syntax ... (3 dots).