Getting Started in TrainzScript

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Creating and Editing Scripts, Tools to Use)
m
Line 1: Line 1:
 
==Script Usage==
 
==Script Usage==
  
* In TRS2004 and later, scripts can be used to make objects perform operations in reaction to events. For example a level crossing (grade crossing) can be made to operate as a train approaches it.
+
* In [[Trainz SP3]], script support was added to allow the creation of scripted scenarios (interactive activities.) While existing scenarios are still usable in [[TS2010]], creation of [[KIND Activity]] assets has not been supported by [[Auran]] since [[TS2006]] and future versions of Trainz will drop support for this asset kind entirely.
* In TRS2004 and later, rules are written as scripts, and these rules can be included in Driver sessions, effectively as the session's program elements.
+
* In [[TRS2004]] and later, scripts can be used to make objects perform operations in reaction to events. For example a level crossing (grade crossing) can be made to operate as a train approaches it.
* In TRS2004 and later, driver commands are written as scripts, and these can also be included in Driver sessions so as to give train drivers a series of operations to perform.
+
* In [[TRS2004]] and later, rules are written as scripts, and these rules can be included in Driver sessions, effectively as the session's program elements.
* In TRS2004, scenarios (interactive activities) are written as scripts. This functionality was removed in TRS2006 and later although by various complex means it can be emulated to a limited extent.
+
* In [[TRS2004]] and later, driver commands are written as scripts, and these can also be included in Driver sessions so as to give train drivers a series of operations to perform.
 +
 
  
 
==Creating and Editing Scripts, Tools to Use==
 
==Creating and Editing Scripts, Tools to Use==

Revision as of 20:00, 15 February 2010

Script Usage

  • In Trainz SP3, script support was added to allow the creation of scripted scenarios (interactive activities.) While existing scenarios are still usable in TS2010, creation of KIND Activity assets has not been supported by Auran since TS2006 and future versions of Trainz will drop support for this asset kind entirely.
  • In TRS2004 and later, scripts can be used to make objects perform operations in reaction to events. For example a level crossing (grade crossing) can be made to operate as a train approaches it.
  • In TRS2004 and later, rules are written as scripts, and these rules can be included in Driver sessions, effectively as the session's program elements.
  • In TRS2004 and later, driver commands are written as scripts, and these can also be included in Driver sessions so as to give train drivers a series of operations to perform.


Creating and Editing Scripts, Tools to Use

  • Trainz scripts need to be included in your asset folder as plain text files.
  • Any errors in the script, including spelling or syntax errors, won't be flagged up until you load a map which uses your asset or when you first place your asset on a map.
  • Although you can use Notepad to create and edit files and commit them directly to the game, it will quickly become frustrating having to run TRS to find that you have missed out a semicolon or closing quote.
  • TRS includes a command line compiler called gsc.exe, at C:\Program Files\Auran\TRS####\Bin\, which can be used to check script syntax, this won't guarantee that your script will work but it will guarantee that TRS will accept it as valid.
  • Editors which will help you to ensure that your scripts are correctly formatted are freely available, one such is Context and details of how to obtain it and set it up for Trainz are included at this page: Using Context with Trainzscript. Another such program is TextPad (http://www.textpad.com).

Tutorials

The following are links to various tutorial pages available for TrainzScript:

For Beginners:
A set of tutorials by Andi Smith which will take you through the steps involved in setting up a simple script on a scenery asset, starting with the traditional 'Hello World' and ending with the use of a Property Interface to deal with basic effects, including animation, sounds and texture replacement. The tutorials largely avoid object-oriented terms such as encapulation, inheritance and polymorphism, and instead try to concentrate on getting your scripts working as quickly and painlessly as possible.

  1. Hello World, Setting Up An Asset Script.
  2. Getting Information From the Game, Writing Your Own Methods.
  3. Talking to Yourself, Sending Messages.
  4. Saving and Restoring Data, Using Properties.
  5. Setting Up the Asset.
  6. Automating Animations.
  7. Handling Corona Effects.
  8. Playing Sounds.
  9. Hiding Meshes.
  10. Handling Name Effects.
  11. Texture Replacement.
Personal tools