![]() |
![]() |
|
Home > Tutorials > Setting up scripting syntax for Trainz Scipt
Setting up scripting syntax for Trainz Script The information contained on this page is the method used by myself and is not considered to be either a standard or a recommended protocol for laying out trainz script but in my opinion it makes navigation and identification much easier.
|
Protocols The following items are used for highlighting the syntax that I use when creating scripts. I always prefix variables with a three digit lower case value. For exampe a string will always have a prefix of str. That way I can always tell at a glance what a variable is. In the case of an array or a public variable I add a further prefix of either an a or p respecitvely. This is useful to quickly identify an array or a public string. Another protocol that I follow is to always have the opening curly bracket (or braces or Nances) on the same line as the statement. For example' if (intX == intY) { I follow this protocol for functions and classes as well. If you use the syntax highlighting text listed below then this protocol must be followed in order to allow UltraEdit to identify the functions in the script. I also follow another protocol in regards to classes and custom functions. With classes I prefix a lower case cls to the class name and with function I prefix cfn to the function name. This has two effects, one it allows the highlighter to find the function easier and two it keeps all my custom functions together in the function list. \ Finally the last protocol that I follow and from what I have seen most other sciptors use as well and that is to indent each new statement with two additional spaces to its predessor as follows; class es44ac isclass Locomotive { This allows the start and end of statments and functions to be followed through and allows easier identification of missing curly brackets.
|
The following is a complete list of variable prefixes that I use. Do not add this section to your UltraEdit highlighters.
Following is the Trainz Script and Trainz Config highlighters. Make sure you add these to the end of the Wordfile. This file can be accessed via the "Advanced", "Configuration" menu and then select "Editor Display" and then "Syntax Highlighting" If you already have L10 and L11 languages added to the wordfile then you will need to index the L10 and L11.
|
/L10"TrainzScript" Line Comment = // Block Comment On = /* Block Comment Off = */ String Chars = "' File Extensions = GS /C8"TrainzScript_Curly_Brackets"
/L11"TrainzConfig" Line Comment = ; String Chars = " File Names = CONFIG.TXT CONFIGTRS2004.TXT /C3"TrainzConfig_Attachments" > /C8"TrainzConfig_Operators" |
| Was this tutorial helpful? Not enough or too much detail? Points not explained properly? Suggest any improvements? Please use the Tutorial Enquiry Form |
Trainz and Trainz Railroad Simulator are trademarks of AuranBest viewed at 1024 x 768 or higher Pages best viewed with Cooper and Cooper Black font installed. Copyright © 2007
P. Campbell. All rights reserved. Revised:
February 17, 2008
|