Subroutines (GTA2)

Main Page > GTA2 > Modding Tutorial > Subroutines


Subroutines are used to easily "jump" to a set of commands within the script.

Subroutine:

A subroutine is created with the next command:

name:
//code goes here 
RETURN
name An unique name for the subroutine. Note the : at the end of the name!
RETURN This closes the subroutine. Every command in the subroutine has to be between the name: and RETURN.

You can script the subroutine where ever you want, even before LEVELSTART!

FORWARD

To activate a subroutine at the start of the game, use this command:

FORWARD name:

The FORWARD must be before LEVELSTART

GOSUB

To jump to the subroutine mid-game, you use the next command:

GOSUB name:

Again, don't forget the : at the end of the name. A GOSUB can be everywhere where you want to jump to the subroutine: inside an IF, a WHILE, etc, as long as it's after LEVELSTART.

Modding tutorials of Grand Theft Auto 2
Mapping Map Editor · Buildings · Roads · Water & animations · Slopes · Flat tiles · Collision info · Level edge · Zones · Putting a level ingame
Scripting Declarering: Main script · Script Compiler · Code lists · Commands · Vehicles · Objects · Sounds · Characters
Programming: IF · WHILE · COUNTERs · Subroutines · THREAD TRIGGERs · Kill Frenzies
Both Manual · Lighting · Car shops · Cranes & crushers · Gangs · Subway · Multiplayer levels
File types .gci · .gmp · .gxt · .mis · .mmp · .scr · .seq · .tmp · .sty
Other Texting · Physics · Creating vehicles · Terminology · Installing levels