Script Include Directive

From TrainzOnline
Revision as of 21:27, 10 July 2013 by Mjolnir (Talk | contribs)

Jump to: navigation, search

A script written in the TrainzScript language is stored in one or more ".gs" files within an asset. One of these script, referred to as the asset's "primary script", is referenced from the asset's config.txt file. Any additional ".gs" files within the asset may then be referenced from within a script file by using the "include" directive.


Contents

Example

TBD.


Cross-Asset Includes

Script files from other assets can be included through the use of an "script-include-table" tag in the parent asset's config.txt file. This causes the asset to become dependant on the specified child assets, and makes it possible to directly include the child assets' script file(s) from the parent asset's script file(s). If the child asset is a KIND Library, the parent asset may use World.GetLibrary() to gain a reference to the library, as demonstrated here.

This will then allow you to call public functions in the library directly without needing to use the Library.LibraryCall() syntax.

Circular Includes

Circular inclusion is not permitted. Examples of circular inclusion are "A includes B includes A" or "A includes B includes C includes A" (where A, B, C are script files.)


Scripts with Identical Names

The content creator must avoid any situation in which multiple script files (at different file paths) have the same file name. The outcome is undefined.

The content creator must avoid any situation in which multiple script files (regardless of the file name) which define same-named script classes are included at the same time. The outcome is undefined.

Categories

Personal tools