Game script

From OpenTTD
Jump to: navigation, search

OpenTTD allows you to write your own Game Scripts. These scripts can provide goals for all companies, inspect properties of all companies and also communicate with the players of companies.


Feature availability

<1.0

1.0-1.2

1.3

1.4

Nightly


Gamescript or NoGo provides the possibility of adding goal-based scripts to the game via a framework similar to the NoAI framework using the Squirrel programming language.

'Gamescripts' can modify the way towns behave, delete objects, place new in-game industries, and town buildings, as well as inquire about the state of the game, and do several other in-game actions. Gamescript files may be downloaded and selected for activation prior to creation of a new game in order to introduce these features. Unlike Advanced Settings which may be changed part way through a game, Gamescripts should be installed prior to starting a new game in order to ensure correct operation. Gamescripts are not supported by TTDPatch, and are introduced, and supported by, OpenTTD version 1.2.0 and later.

For common issues with Gamescripts, visit the Gamescript FAQ

Contents

Getting Gamescripts

Online content

The most common and convenient way to obtain gamescripts is by using the ingame online content download feature. Most Gamescripts can be found there. There exists also a Gamescript forum where you may find development versions of some gamescripts.

Manual install

If you want to use gamescripts installed from other locations, which are not available from the online content download, you need to manually install them into the correct place. A gamescript is either a tarball or .tar file, or a directory with several code files. To install a gamescript:

  1. Download the gamescript file(s).
  2. Move (and uncompress) the gamescript file(s) to the gamescript directory of your OpenTTD installation.
  • This will often be:
C:\My Documents\game (Windows 95, 98, ME)
C:\Documents and Settings\<username>\My Documents\OpenTTD\game (Windows 2000, XP)
C:\Users\<username>\Documents\OpenTTD\game (Windows Vista, 7)
~/.openttd/game (Linux, BSD)
~/Documents/OpenTTD/game (OSX)

Activating Gamescripts

1. In the main menu, click "AI/Gamescript Settings".

2. Select the text in the box under "Gamescript"

3. Click the top-left-most button in the bottom menu labeled "Select Gamescript"

4. Pick a gamescript of your choice from the pop-up menu.

Setting Gamescript parameters

1. In the main menu, click "AI/Gamescript Settings".

2. Select the text in the box under "Gamescript"

3. Click the 'Configure' button.

4. A row of parameters defined by the gamescript will show up. Change the desired parameters and click the 'Close' button to implement the changes. Use the 'Reset' button to set all parameters back to default values.

Writing your own game script

When you write a Game Script, you code it in a programming language called Squirrel. The framework used for GameScripts is called NoGo and share many aspects with the AI framework called NoAI.

For historical reasons there are plenty of wiki articles on how to write AIs, but very few with the Game Script perspective. Thankfully Game Scripts are very similar to AIs only that they don't have ownership of a specific company. Thus the AI articles are still of great help on how to write Game Scripts.

  • Read the AI section (lots of material apply to Game Scripts too)
  • See the external links below for more resources (API docs, Squirrel docs, existing game scripts, ..)

When working with your GS you should store your files in $OpenTTD/game. Make a directory there for your GS eg. $OpenTTD/game/myGS and put the .nut files in there. Note that you should not store them in $OpenTTD/online_content/game as that the online_content directory is managed by OpenTTD and may overwrite your files etc.

External links


Template:Navbox Gamescript

Personal tools