Note: This chapter is not meant to teach the user how to script with Lua. To learn how to program in Lua please visit the The Programming Manual.

Global PropertiesEdit

The global properties is a window that lets you control the lighting, the gravity of the entire game, which Lua script is executed when the game starts, and other settings for Facebook integration. The Gravity Property (located in the Physical Properties tab) is a force that is applied to every object in the frame. It's an XYZ vector with a default value of (0,0,-9.8). That means that a force of 9.8 newtons will be applied to every object in the Z axis downwards (since it's negative), causing the object to fall. If the gravity was (1,0,1) every object would float up and to the right slowly.

In the Visual Properties tab you will find the properties that control the scene's directional lights. You can set these manually by setting the light's HPR (click here [9] to view a diagram that will help understand how angles translate into directional lights), or you can use the Light Widget to set up the lights directions (click show widget and move the little spheres around until you are happy with the lighting). You can also set a light's color, to do that just click on one of the colored bars.

The only other Tab in the Global Properties window is the "Script Properties" tab, which contains properties to set up Facebook integration and the location for the scene script, which is described bellow.

For more information regarding Facebook integration, check these resources:

Scene ScriptEdit

The scene script is the main entry point for your game, so it's very important that you know how to create and use your own scene script in order to be able to program anything in Wild Pockets.

The scene script can contain all the data and logic for your game, and if you're using other scripts it will be responsible for loading and initializing the various modules (classes) that your game will use.

To learn more about modules, classes, and logic please refer to Chap. 07A --- The Module System [12]in the programming tutorial.

Everything that you write on the scene script gets executed when the game starts, but it's considered good practice to put all of your initialization code within the onSceneStart function. For example:

Chap4 pt1

Creating and Uploading ScriptsEdit

Before you start creating and editing scripts you need to get a good programmer's text editor. We recommend you get Notepad++ [13] since it contains support for Lua syntax right off the bat. So go download and install that.

You can't create files in the server directory, so we're going to create the scripts in the local folder and then sync them up to the server. To do this open the local folder ("Folders -> Open Local Folder"). Then navigate to the directory you want to create your script in. Since .lua files are nothing but text files, we can just hit "Right-Click -> New -> Text Document" and rename the document to be "scriptName.lua".

When creating the scene script it's a good idea to call it a distinct name, such as "main.lua" or "mainScript.lua".

When you create the script, open it with Notepad++ and copy and paste this code into it (don't forget to save):

Now that the script is complete, we need to assign it to the project. First we sync the folders, so that the script gets uploaded to the server. Once you've done that open the Global Properties window, and click on the "script Properties" tab. You will see a "Script File:" value, by default it will be assigned to a default scene script that the Wild Pockets team has created, you want the program to use your script instead, so click the (...) button, navigate to the folder that contains your scene script, and double click the script to assign it.

Now if you hit "Debug -> Begin Test" and open the Debug Console, you will see "HEY WORLD, IT'S ALIVE!!" printed on the console output.

The Wild Pockets APIEdit

The Wild Pockets API (Application Programming Interface) is a collection of Lua classes and functions that allow the developer to manipulate and use the game engine's features and functionality to create their games.

The API Reference [14] is a complete list of every class and every function that the developer can use, with descriptions for function behaviors and parameters. This a resource that you will constantly reference as you learn how to use Wild Pockets. The Builder and Programming manuals cover a lot of information and explain how to accomplish common game programming tasks using Wild Pockets, but there is so much more that the engine can do that we have not yet had the chance to document, please explore. We plan to continue to expand the documentation and we will also soon allow developers to contribute to the documentation. The API Reference contains all of the functionality of the engine, and it is always up to date. So become familiar with it.

Note: Check this out [15], Nikkio made an autocompletion plugin for Notepad++, now you can have the entire API Reference in the editor itself!

Using the built-in HelpEdit

The Function Documentation window can be accessed by clicking "Help -> Function Documentation" on the menu toolbar, or you can click on the Function Documentation tab on the right side of the screen.

This window contains the entire API Reference [14] right within the builder. It even lets you search for a particular class or function. This is a very powerful resource that you will use frequently as you learn how to script in Wild Pockets.