Skyline Game Engine Store uses cookies to store certain information to make your site visit more enjoyable. By proceeding to use the store, you are agreeing to the use of cookies.

Artists Guide to Lua Part-1

Posted by SolarPortal 22/01/2018 0 Comment(s)

Skyline uses the industry standard Lua with most of the standard lua features available. On top of this Skyline ships with a large set of interface libraries providing script access to many of Skylines core features to enable you to leaver the most out of the toolset.

I am not a scripter and never really got my head around code.

"I am not a scripter and never really got my head around code." We hear this quite often as many people we have met are art driven, but being just an artist in todays game development environment can slow you down with seeing your ideas come to life. We developed Skyline to be as artist driven as possible as we don't want to spend ages scripting, but there are time when you just can not get away without some code!

This is where I see you run away screaming you won't get me coding!

This is where I see you run away screaming you won't get me coding!

with me on this as I will show you that scripting is not that intimidating as you may think. There are many people who would love you to think they are gods of code and hide behind terminology and complicated line of numbers and symbols that looks like some form of techno voodoo. Yes there are some real geniuses of code but to make you game you don't need to be one. Heres an analogy for you; You can ride a bike, maybe even ride off road but there are some crazy people who can ride to extreme levels making huge jumps and somersaults or riding down mountains, yet you can still ride a bike!

Ah I see you are still here with me. Ok I will be very gentle with you and introduce some of the basic things you will need to know. Dont worry about remembering these as you will see them so many times that they will become second nature, but the first time you see them you will just want to flee.

Syntax: the scripts punctuation, but way easier that your distant memories of school days past and run ins with the English teacher and grammar. Lua has some of the most relaxed punctuation of the scripting languages so if a terminator is forgotten you will not be punished. Note that the terminator is a character that denotes the end of a line of script not some type of metal Arnie crazy machine.

EG: physics.setMass(100);
see the ";" semicolon on the end, this is a line terminator.Also while we are here lets look at that command

Command: The scripts instruction to Skyline. A command is the this we use to tell Skyline and Lua to do something. So on closer inspection the command is made up of three parts; the library, the actual command and the value. The dot between the library and the command is for a better word, a lua separator.

Library . Command( Value )
physics . setMass(100);

One last this to mention is that not all commands can use a value this is relevant to each specific command and what the command does. Some commands just have empty parentheses ( ) but you must always add the command parentheses or the script will not work. Dont worry about remembering what commands do what you can reference the Skyline API for this information but we will look at this later.

One last thing to mention before we shoot off is that some commands can get information from Skyline and example of this could look like this:

EG: myValue = physics.getMass();

In this case we have the use the "=" sign, yeah I know this is looking like a math formula but trust me its not! Its more like a real world task like holding a box then picking some apples and putting them in the box. In our example the "myValue" is our box and the picking action is the "=" character. Lets look at our analogy written as script.

[ box           ]  [ picking ]      [ tree . getApple          ]   Fills the box with apples
[ myValue ]  [       =       ]      [ physics . getMass(); ]   Fills myValue with mass value

Well thats it for now, in the next blog we will look at another important description before moving onto some Skyline fun!
*Code Flow
See you next installment :)

Leave a Comment