Aurora,
Sorry for taking so long. I lost this thing twice so I hope you will find it useful. Gotta go get some sleep now.
Rick
AGS Quick Tutorial: Opening/Closing a Gate
by Rick Jafrate
INTRODUCTION
This tutorial assumes the reader has some familiarity with the operation of the AGS editor. There are other well illustrated tutroials showing how to use the various features of the editor so it makes little sense to cover the same material here in a less adequate text format. Check the sticky posts in the beginner's forum.
SCRIPTING OVERVIEW
Scripts
A script file contains a collection of statements or instructions that are executed by the AGS Game Engine. Such statements are normally terminated by a semi-colon character, ";". In AGS there is a global script file and one room script file for each room. The global script is always active and only one room script file is active at any given time (i.e. the room script associated with the current room). The AGS scripts are very similar to the "C" programing language,
Comments
Comments are good things
. Although they don't have any affect on the compiler or game engine they do keep us poor stupid humans out of a lot of trouble. A comment is denoted by the occurance of double slash characters "//". The "//" characters and the remaining portion of the line are ignored by the compiler and are meant purely for human consumption.
Variables
A variable is a portion of memory that has been given a name and a data type. The name is associated with a physical memory location by th AGS compiler and/or game engine. The data type determines how much memory must be allocated to accomodate the kind of data to be stored here. The most commonly used data types are string, and int. A string variable is used to store text and an int variable is used to store numeric/integer values. Variables are defined in a script file by first entring th data type followed by the name as follows:
Functions
A function is a container for script statements (or instructions). Such statements consist of basic constructs such as if/else, assignemnts, integer arithmetic, and calls to other functions. Note: Math is evaluated from right to left in AGS and sometimes produces unexpected results. Functions must be defined before they are used. There are a number of functions that are pre-defined by AGS and are explained in the help document. Functions return data, by default they return int data. Because of this they can be used like variables. An example function is defined below that doubles a value and returns the result.
Events
The AGS Game Engine executes scripts in response to the player's interactions with the game. Programmers refer to such interactions as events. Programs that are executed when an event occurs are referred to as event handlers.
Interaction Editor
Event handler functions are created using the AGS interaction editor. Select the desired interaction and then click on "Run Script" from the drop menu to create an event handler function. The function name will be automatically assigned so don't modify the name or definition of such functions.
continued ...
Sorry for taking so long. I lost this thing twice so I hope you will find it useful. Gotta go get some sleep now.
Rick
AGS Quick Tutorial: Opening/Closing a Gate
by Rick Jafrate
INTRODUCTION
This tutorial assumes the reader has some familiarity with the operation of the AGS editor. There are other well illustrated tutroials showing how to use the various features of the editor so it makes little sense to cover the same material here in a less adequate text format. Check the sticky posts in the beginner's forum.
SCRIPTING OVERVIEW
Scripts
A script file contains a collection of statements or instructions that are executed by the AGS Game Engine. Such statements are normally terminated by a semi-colon character, ";". In AGS there is a global script file and one room script file for each room. The global script is always active and only one room script file is active at any given time (i.e. the room script associated with the current room). The AGS scripts are very similar to the "C" programing language,
Comments
Comments are good things

Variables
A variable is a portion of memory that has been given a name and a data type. The name is associated with a physical memory location by th AGS compiler and/or game engine. The data type determines how much memory must be allocated to accomodate the kind of data to be stored here. The most commonly used data types are string, and int. A string variable is used to store text and an int variable is used to store numeric/integer values. Variables are defined in a script file by first entring th data type followed by the name as follows:
int MyVar;
Functions
A function is a container for script statements (or instructions). Such statements consist of basic constructs such as if/else, assignemnts, integer arithmetic, and calls to other functions. Note: Math is evaluated from right to left in AGS and sometimes produces unexpected results. Functions must be defined before they are used. There are a number of functions that are pre-defined by AGS and are explained in the help document. Functions return data, by default they return int data. Because of this they can be used like variables. An example function is defined below that doubles a value and returns the result.
// This function doubles the value and returns th result // The first line defines the name of the function and // the parameters that is uses. In this case DoubleIt // is the function name. It requires one parameter which // is an integer named value. The curly braces {} are // used to enclose the functions contnts. function DoubleIt(int value) { // Create a variable in which to store th result int temp; // Calculate result temp = value + value; // Return the result return temp; }
Events
The AGS Game Engine executes scripts in response to the player's interactions with the game. Programmers refer to such interactions as events. Programs that are executed when an event occurs are referred to as event handlers.
// Within the bounds of a subsequent event handler function // in the same script file the DoubleIt() function could be // used as follows: function room_a() { // AGS interaction triggers this function to execute Myvar = DoubleIt(10); // Set MyVar equal to 20 }
Interaction Editor
Event handler functions are created using the AGS interaction editor. Select the desired interaction and then click on "Run Script" from the drop menu to create an event handler function. The function name will be automatically assigned so don't modify the name or definition of such functions.
continued ...