This part of the documentation describes how to use the scripting system in GluonEngine to build your own game logic - best practices and introduction guides are shown along with code samples that you can use directly in your games.
When you hit the limit of the capabilities of the many Components provided by GluonEngine, it is time to create your own game logic. This is where the QtScript Component comes in. Using this component, you can use ECMA-Script (better known as JavaScript) to react to changes in the game world, and make changes to the world in return. The scripts are written in version 1.5 of the language, using the powerful QtScript engine, which is based on JavaScriptCore. If you are familiar with JavaScript from web developing you are in good shape, but its important to note that web browser specific extensions like DOM and some functions are not available.
The following is an introduction to how these scripts are written, and how they access the various parts of the game. If you are looking for the full scripting API, please look at the following links which are helpfully collected by the Amarok team, who use the same scripting engine:
There are also many other JavaScript guides and tutorials on the Internet. Though often web-browser oriented, many are still relevant.
Before you start working with building scripts for game logic, you should know how The GameObject Hierarchy works. The reason for this is that when constructing game logic you will be interacting heavily with that hierarchy. The following image shows how it all fits together:
image showing the hierarchy, and a "you are here" marker to show where the script object sits
To enable you to interact in a simple manner with the other parts of the game, the most immediate of each of the four classes of objects in the hierarchy, you have available to you the following five special objects: