Scripting: Overview

Skyline uses Lua for its scripting language and SGE Lua has be hugely extended with most of the engines core features:

  • Simple scripting – Quick to learn but very powerful in experienced hands
  • Full Lua library – From what you already know plus more new commands.
  • Custom Skyline Engine libraries – Providing commands for accessing most of Skylines core features.
  • Dynamic Properties, User object Property gui controls – Customize your script from the property panel
  • Multiple script sources – Object, Scene, QT Custom Editor

Skyline is an event driven system meaning that when something happens in the scene, there is an event created and passed to the many mechanics systems. This saves on performance costs that you would get by running a main loop, this is not necessary. The events are covered in the event section of this topic. I am not going to go into how to program in Lua as there are loads of great learning resources out there on the web. This is to cover the Skyline specific Lua areas and features.

Scripting Types

Before I show you how to get your hands on a script, let’s first have a look at the script options to help us better decide which script system to use. SGE has scripts for different types of use, these areas are:

  • External Script – Shared by any object:

This script resides on your hard drive and can be referenced by any object from any scene. Great for when you want to make an update to the script then all objects referencing this script will also update. Downside is that all scripts remain the same and any customisation is done via the dynamic properties. These are used a lot in the game objects where systems can develop and grow then all projects using them are automatically updated.

  • Micro Script – Per object only:

This script resides on the object but can also have the dynamic properties. If you want a custom one off script then this keeps it with this object never to be lost, but changes have to be copied to other similar objects. This can be done by copy/paste the script string property to another object. Great for the times when temporary testing an idea where you don’t care about the script. Still can be used in the game objects due to the dynamic properties but will never update unless you open the script and change it.

  • QT Editor Script – Customize SGE Editor:

Provide new editor side features by designing a QT interface and controlling this with an editor script. This is a big topic so for more info please go to that section of the documentation. The Lua libraries for this script type have been increased to provide access to the editor.

  • Run script – Editor Side script:

This is another script system that will run any Lua script good for set up scripts to quickly assign actions and properties to an object. This can be seen in some of the generator scripts and combination scripts. This shares the same libraries as the Custom editor.

  • Scene script – Level script:

This script is a run time script which can be used to run a full game such as space invaders or manage a game level.

  • Module script – Lua Module:

Not so much a script system but a scripting module for simple and quick changes inside the graphical module system.

Which Script Type to use?

Each script type have their own strengths depending upon what you are wanting to achieve.
Simply put when you want to:

  • Have Quick play around – Use a micro script on an object as this will not overwrite any library scripts

  • A Custom object – Micro script

  • Have Re-usability – Use the External script

  • Make a Game Object – Use an External script

  • Control the flow of a game or keep game stats – Use a scene script

  • Design a new Custom Editor – Use the QT editor lua.

  • Create a Combination setup script – Editor Run Script

On top of the following ways to add a script to your object if you happen to find yourself in the Asset Browsers script location, you could just drag the script to an object in the scene. This will give you the option to add it add a micro or external script!