Previous: Introduction

Workshop 01: Getting to know the engine

If you have installed a free or full Gamestudio version on your computer, the program should have an entry in Windows' start menu. In the program group you can see shortcuts to the Lite-C Script editor (SED), to the Model and Terrain editor (MED), to the level editor (WED), and to the manual. Let's see what they do:

- The manual contains the description of all the lite-C functions with examples. We will cover a lot of information in these workshops, but the manual contains the descriptions for many more functions.
- The script editor (SED) is the program that helps us write, execute, compile and debug our lines of lite-C code.
- The model editor (MED) which comes with lite-C allows us to import or create 3D objects (models). Need a terrain landscape for a game level? Use MED to create it! Need a player model? Create it in MED! If you have another favorite 3D editor, you can create your landscapes and models with it, and then import them in MED and save them in the mdl model format used by the engine.

Aren't you anxious to start working? Make sure that you unzipped the litec_samples.zip archive into a folder (not the Gamestudio folder!) on your PC. Fire up the Script Editor SED, click File / Open, navigate to the litec_samples folder that you've unzipped from the archive, and then double click the script01.c file from inside the workshop01 folder.

In the editor you should see something like this:

function main( )
{
   level_load("small.hmp"); 
   ent_create("earth.mdl", vector(10, 20, 30), NULL);
}

This is a small, and yet fully functional lite-C program; let's run it by clicking the black triangle (Test Run) button w02_08 from SED's toolbar.

You will find yourself in a small landscape level; an earth globe model will be hovering in there as well. When you see an error message instead - like "Main Script Not Found - Check Preferences" - you have probably already experimented with SED's settings. Open Options / Preferences / Environment, and make sure that Use the current file for Test Run is checked. Then run the script again.

Press [Alt] + [Enter] to run the program in full screen mode, just like you do with any other Windows application; press [Alt] + [Enter] again to return to the window mode. Press the [0] (zero) key once on your keyboard and explore the level using the arrow keys, [Home] and [End].

That's a nice looking landscape! Examine it for as long as you want, and then press the [Esc] key to shut down the game engine. You're probably curious how to create such a landscape or such a model. They are both created with the model editor MED in a few minutes (well the textures took a little longer), and stored under the file names "small.hmp" and "earth.mdl".

Let's take a look at the code inside script01.c one more time:

function main( )
{
  level_load("small.hmp");
  ent_create("earth.mdl", vector(10, 20, 30), NULL);
}

We can notice several things:

Function main is a special function; it runs automatically at game start, so any commands that inside it will be executed when we press the Test Run button w02_08. As you can see, the first command level_load loads a level named "small.hmp" (our landscape) and the second command ent_create loads an entity named "earth.mdl" at a position of X = 10, Y = 20, Z = 30 in the level, telling it to simply stay there, without doing anything (NULL). What should we do if we'd like to create another earth.mdl entity on top of the previous one? We should add another command to function main, of course!

function main( )
{
  level_load("small.hmp");
  ent_create("earth.mdl", vector(10, 20, 30), NULL);
  ent_create("earth.mdl", vector(10, 20, 55), NULL);
}

Type the new line of code using SED just like you would use your favorite word processor, and then let's Test Run the project again:

It has worked indeed! The second sphere was created at x = 10, y = 20, z = 55, being placed 25 units (quants) above the first one, which has its z set to 30. The vector keyword simply groups together the x, y, z values under the same umbrella; we will talk about all these concepts later, so don't feel guilty ;) if you don't grasp them all at once.

SED gives us quick access to the documentation whenever we need it; click the Command Help tab at the bottom of the screen (if it isn't selected already), and then click any engine keyword - you will see its description, just like in the picture below. This comes in handy if you want to write a command, but you don't remember its parameters.

This simple workshop has taught us how to load a level and how to create and place entities (our earth models) inside it. Don’t worry if you can’t understand how the code works: we'll cover everything in the following workshops. Let's begin with the most basic elements of every programming language in the world: the variables.

Next: Variables