View Full Version : LUA Boot Camp
November 7th, 2008, 06:44 AM
While I am trying to learn yet another language, I figured I would start this thread, which would document all the 'basics' of programming in LUA. The official Girder documentation does contain a lot of information, I spent way too much time trying to find out how to do some of the basic things. So let's put all the useful examples in this thread.
Some basic LUA rules:
LUA is case sensitive
to comment out a line, start the line with 2 dashes. Example: --this is a comment
Ending lines with a semi-colon is optional
Would be great if this thread could be set 'sticky', making it easier to find this basic knowledge.
November 7th, 2008, 06:48 AM
Simple if-else examples:
if varA == 0 and varB == 0 then
Valid operators can be found in the Girder manual (PDF file in your Program Files directory).
November 7th, 2008, 06:52 AM
Splitting a delimited string into a usable array (similar to explode() in PHP). Keep in mind that the array starts at 1, not 0 as in most other languages:
local strTest = "yellow|red|green"
local arrTest = string.Split(strTest, "|")
This would print:
November 7th, 2008, 08:41 AM
personal favorite function
will print the complete array in one go.
January 8th, 2009, 05:50 PM
come on all,
keep 'em coming....
trying to learn Lua
every days a school day....
January 24th, 2009, 12:36 PM
I'm also trying to learn...
When you use print ex. print(arrTest)
Where can you se the output? Could be usefull for debugging i think.
January 25th, 2009, 06:06 AM
The output should appear in the Interactive Lua Scripting Console (see the view menu)
January 25th, 2009, 06:21 AM
So it does. Thanks..
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.