Script Include Directive
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.
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.