Hehehe... I began coding like this:
Code: Select all
10 PRINT "What is your name?"
20 INPUT NAME$
30 PRINT "Hello "; NAME$;"; nice to meet you!"
40 END
And all I had was characters... Ah, those were the days. It made my own start easier, although I had no internet back then (nobody did), so I went in a bit the "hard way". Just trying stuff out, seeing what would happen. It's a hard way to learn, but I guess I could never come where I am now when I didn't try so much back then
Oh yeah, and I know about rude programming communities. Like the Lazarus community where I was told to "learn to code" due to a error in the code written by the Lazarus programmers themselves (and thus not me). Now you can call me a dummy, but I wonder how I am to blame for a code error in Lazarus' own code (the error was "Unknown identifier"). I guess I won't be using Lazarus for my GUI based programs
(All I did was open a template project and try to compile it. Wow, what a lousy programmer I am)
I did find a little mistake in my example code and I fixed that. Sorry, I shouldn't cause confusion.
Mastering the use of tables is a very important aspect of Lua. When trying the "real" languages like C or Pascal you'll have more complex things to deal with, but when you analyse that code well you can see the same principal as the tables in Lua, only in Lua it's heavily simplefied. (Question always is what a "real language" is. I still meet some people who only deem pure assembler code as programming. I guess it depends on who you ask).
Just a few nice thing to know about tables
Code: Select all
a = {} -- create new table. Variable a is the table.
a[#a+1] = "Hello" -- #a is the number of indexes. That's now 0, so 0+1 = 1 so a[1]="Hello" now.
print ( a[1] ) -- prints "Hello"
a[2] = {} -- extra table on a[2]
a[2][1] = "Hi"
print (a[2][1]) -- "Hi"
print (a[1]) -- "Hello"
I shall keep it to this now, as tables can do so much more in Lua. They can basically help you getting you thing solved.
The for command was in this case use to list out all contents of the table with the help of ipairs.
Now try to analyse this and try some stuff out
Also Google is your friend. A lot of questions about the Lua language are answered already by googling it. A lot of solutions for you needs may often not lie in LOVE itself, but rather in Lua itself. Since Lua is used as a scripting language for many things, Lua help pages can deal with quite a lot of stuff. (And bookmark stackoverflow.com -- In 90% of the cases when I have any question about any programming language (aside from Lua I also work in BlitzMax, php, Python, Pascal and Go) somebody else already asked it there before and answers are mostly already provided
