Make your own free website on Tripod.com

A.G.S. v2.21
Text Script Commands Manual by Spyros

Main Page
Character

Cursor
Dialogue
Display
File
Game
GUI
Inventory
Music,Sound,Flic

Palette
Object

Room
Screen
String

 

CallGlobalScript (int value)
Once the current script has finished, this will pass control on to the global script's "gscript_request" function, passing VALUE as the parameter to it. This allows you to have common code in the global script which you can call from room scripts.
NOTE: The global script doesn't get called until your room script finishes.
Example:
CallGlobalScript (10);

Debug (int command, int reserved)
This function provides all the debug services in the system. It performs various different tasks, depending on the value of the COMMAND parameter. If debug mode is off, then this function does nothing. This allows you to leave your script unaltered when you distribute your game, so you just have to turn off debug mode in the Room Editor.
The RESERVED parameter is currently unused and you should always pass 0.
All the valid values for the COMMAND parameter are listed below along with what they do:
0 All inventory - gives the current player character one of every inventory item. This is useful for testing so that you don't have to go and pick up items every time you test part of the game where they are required.
1 Display interpreter version - the engine will display its version number and build date.
2 Walkable from here - fills in the parts of the screen where the player can walk from their current location. This is useful if you think the path-finder is not working properly. Yellow areas are where the man can walk. Blue areas are defined as walkable in the Room Editor, but he cannot get to them from his current position. The unaltered parts of the screen are not walkable.
3 Teleport - displays a dialog box asking for what room you want to go to, and then calls NewRoom to teleport you there. Useful for skipping parts of the game or going to a specific point to test something
Example:
Debug (2,0);

IsTimerExpired (int timer_id)
Checks whether the timer TIMER_ID has expired.
If the timeout set with SetTimer has elapsed, returns 1.Otherwise, returns 0.
Note that this function will only return 1 once - after that, the timer
is placed into an OFF state where it will always return 0 until restarted.
Example:
If timer 1 expires then Global Int 10 is set to 1.
if (IsTimerExpired(1)==1) SetGlobalInt(10,1);

GetGameSpeed ()
Returns the current game speed (number of cycles per second).
Example:
SetGameSpeed (50);

GetGlobalInt (int index)
Returns the value of global variable INDEX.
Example:
GetGlobalInt (10);

GetSaveSlotDescription (int slot, string buffer)
Gets the text description of save game slot SLOT into the provided BUFFER.
If the slot number provided does not exist this function returns 0, if successful it returns 1.
Example:
GetSaveSlotDescription (2,buffer);

GetTime (int whichvalue)
This function returns various values, representing the current system time.
You could use this for timing a loop, or for effects like telling the player to go to bed, and so on.
The WHICHVALUE parameter controls what is returned:
1 current hour (0-23)
2 current minute (0-59)
3 current second (0-59)
4 current day (1-31)
5 current month (1-12)
Example:
GetTime (1);

GiveScore (int score)
Adds SCORE to the player's score. This is preferable to directly modifying the variable since it will play the score sound and make sure that the status line is updated. Note that SCORE can be negative, in which case the score sound is NOT played.
Example:
GiveScore(1);

IsGamePaused ()
Returns 1 if the game is currently paused, or 0 otherwise. The game is paused when either the icon bar interface has been popped up, or a "script-only" interface has been displayed with InterfaceOn. While the game is paused, no animations or other updates take place.
Example:
IsGamePaused();

PauseGame ()
Stops the engine processing character movement and animation, and other game features. This has the same effect on the game as happens when a script-only interface is popped up. The processing will not resume until you call the UnPauseGame function.
Example:
PauseGame();

ProcessClick (int x, int y, int mode)
Simulates clicking the mouse on the location (X,Y) on the screen, in the cursor mode MODE. Any conditions attached will be executed.
 NOTE: This function ignores all interfaces and acts as though the point is directly visible. In other words, if the co-ordinates you pass happen to lie on a button on an interface, what actually happens will be as if the user clicked behind the interface onto the actual screen.
Example:
ProcessClick (100, 50, MODE_LOOK); will simulate clicking the mouse on co-ordinates (100,50) in the Look mode.

QuitGame(int ask_first)
Exits the game and returns to the operating system (DOS, Windows, etc).
If ASK_FIRST is zero, it will exit immediately. If ASK_FIRST is not zero, it will first display a message box asking the user if they are sure they want to quit.
Example:
QuitGame (1);

Random (int max)
Returns a random number between 0 and MAX. This function is provided in the hope that someone might find it useful - I can't think of anything to use it for.
Example:
Random(10);

RestartGame ()
Restarts the game from the beginning.
Example:
RestarGame();

RestoreGameDialog ()
Displays the restore game dialog, where the player can select a previously saved game position to restore.
The dialog is not displayed immediately; instead, it will be displayed when the script function finishes executing.
Example:
RestoreGameDialog ();

RestoreGameSlot (int slot)
Restores the game position saved into slot number SLOT. You might want to use these specific slot functions if for example you only want to allow the player to have one save game position rather than the usual 20. If this slot number does not exist, an error message is displayed to the player but the game continues. To avoid the error, use the GetSaveSlotDescription function to see if the position exists before restoring it.
NOTE: The position will not be restored immediately; instead, it will be restored when the script function finishes executing.
Example:
RestoreGameSlot (3);

SaveGameDialog ()
Displays the save game dialog, where the player can save their current game position. If they select to save, then the game position will be saved.
Example:
SaveGameDialog ();

SaveGameSlot (int slot, string description)
Saves the current game position to the save game number specified by SLOT, using DESCRIPTION as the textual description of the save position. Be careful using this function, because you could overwrite one of the player's save slots if you aren't careful.
The SaveGameDialog function uses slots numbered from 1 to 20, so if you don't want to interfere with the player's saves, I would recommend saving to slot numbers of 100 and above.
Example:
SaveGameSlot (10, save);

SetGameSpeed (int new_speed)
Sets the game speed to NEW_SPEED frames per second, or as near as possible to that speed. The default frame rate is 40 fps, but you can speed up or slow down the game by using this function. Note that this speed is also the rate at which the Repeatedly_Execute functions are triggered.
The NEW_SPEED must lie between 10 and 100. If it does not, it will be rounded to 10 or 100. Note that if you set a speed which the player's computer cannot handle (for example, a 486 will not be able to manage 80 fps), then it will go as fast as possible.
NOTE: Because the mouse cursor is repainted at the game frame rate, at very low speeds, like 10 to 20 fps, the mouse will appear to be jumpy and not very responsive.
Example:
SetGameSpeed (50);

SetGlobalInt (int index, int value)
Sets the global variable INDEX to VALUE. You can then retrieve this value from any other script using GetGlobalInt.
There are 100 available global variables, from index 0 to 99.
Example:
SetGlobalInt (10,2);

SetRestartPoint ()
Changes the game restart point to the current position. This means that from now on, if the player chooses the Restart Game option, it will return
here. This function is useful if the default restart point doesn't work properly in your game - just use this function to move it.
Example: (make a restart point where the player starts at room2 instead of intro.crm )
In the Global Script make a function restart, then:
function restart() {
SetRestartPoint();
NewRoomEx(2,120,100); }

SetTimer (int timer_id, int timeout)
Starts timer TIMER_ID ticking - it will tick once every game loop (normally 40 times per second), until TIMEOUT loops, after which it will stop.
You can check whether the timer has finished by calling the IsTimerExpired function.
Pass TIMEOUT as 0 to disable a currently running timer.
There are 10 available timers, with TIMER_IDs from 1 to 10.
Example:
Make a timed action. This will let the player make an action in a certain amount of time
In the INTERACTION SCRIPT:
SetTimer(2,200);
In the REP.EXECUTE :
if (IsTimerExpired(2)==0) // allow the player to make the action
else // Do not allow the player to make the action

UnPauseGame ()
Resumes the game.
Example:
UnPauseGame ();

Wait (int time)
Pauses the script and lets the game continue for TIME loops. There are normally 40 loops/second (unless you change it with SetGameSpeed), so using a value of 80 will wait 2 seconds. Note that no other text scripts can run while the Wait function is in the background.
Example:
Wait (60);

WaitKey (int time)
Pauses the script and lets the game continue until EITHER:
(a) TIME loops have elapsed, or
(b) the player presses a key
Returns 0 if the time elapsed, or 1 if the player interrupted it
Example: ( Pause the game for 5 seconds or until tha player presses a key):
WaitKey(200);

GLOBAL VARIABLES

*game.items_per_line
 Number of inventory items displayed per line (useful for working out how much to scroll the window down)
Example:
game.items_per_line=4;

*game.num_inv_displayed
Number of inventory items which can be seen in the inventory window.
Example:
game.num_inv_displayed=8;

*game.num_inv_items
Number of different inventory items which the current player is carrying.
Example:
game.num_inv_items=12;

*game.score
The player's score.
Example:
game.score=2

game.sierra_inv_color
The background color of the sierra-style inventory.
Example:
game.sierra_inv_color=34;

game.top_inv_item
Index of the first inventory item in the window
Example:
game.top_inv_item=1;

game.used_mode
 Cursor mode used with last click (use with "any click" events to find out which mode was used)
Example:
game.used_mode=3;

gs_globals[50]
The graphical script global flags (0=clear, 1=set)
Example:
gs_globals[3]=1;

*system.color_depth
The color depth (8 or 16).
Example:
system.color_depth=8;

*system.os
Interpreter version (1=AGS-DOS, 2=AGS-WIN).
Example:
system.os=1;