Script Include Directive

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (Cross-Asset Includes: Added note about referenced assets.)
(Categories)
Line 28: Line 28:
 
== Categories ==
 
== Categories ==
  
[[Category:TBD]]
+
[[Category:TrainzScript]]

Revision as of 14:29, 17 January 2014

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.

Assets referenced through a script-include-table must already exist on the DLS or contained in the same package (cdp) being uploaded to the DLS.

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