KIND Library

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (Added sort criterion)
m (Changed tag description layout to similar pages. Unsure about tag "tni-library-name". Please delete if wrong.)
Line 11: Line 11:
 
==Supported Tags==
 
==Supported Tags==
 
Each Library asset supports the following tags. Each tag is shown here with its default value.
 
Each Library asset supports the following tags. Each tag is shown here with its default value.
* ''always-load-in-global-context'' if set to '1', library is always loaded to [[New_TrainzScript_Features#Global_script_context|global script context]]
+
 
* ''controlset'' specifies a [[KIND Controlset|controlset]] asset to link to this library
+
kind "library"
 +
always-load-in-global-context ""
 +
controlset ""
 +
tni-library-name ""
 +
 
 +
 
 +
====always-load-in-global-context====
 +
:Type: bool
 +
:Desc: if set to '1', library is always loaded to [[New_TrainzScript_Features#Global_script_context|global script context]]  
 +
====controlset====
 +
:Type: KUID
 +
:Desc: specifies a [[KIND Controlset|controlset]] asset to link to this library
 +
====tni-library-name====
 +
:Type: string
 +
:Desc: TBD
  
 
==Example Config.txt==
 
==Example Config.txt==

Revision as of 18:16, 15 March 2014

KIND Library is a coded module that interacts with other coded modules.

Contents

KIND Hierarchy

Parent Classes

Child Classes

  • none.


Supported Tags

Each Library asset supports the following tags. Each tag is shown here with its default value.

kind "library"
always-load-in-global-context ""
controlset ""
tni-library-name ""


always-load-in-global-context

Type: bool
Desc: if set to '1', library is always loaded to global script context

controlset

Type: KUID
Desc: specifies a controlset asset to link to this library

tni-library-name

Type: string
Desc: TBD

Example Config.txt

Sample config.txt file for a library asset, with the Standard Tags excluded for brevity:

kind   "library"
script "LibraryScript.gs"
class  "LibraryClass"

Typical Usage

Library assets allow content creators to develop script code which can be shared between multiple assets. A library asset is loaded into a session only once, by the first asset to reference it, and all subsequent assets are given a reference to the same library. This enables a clean form of inter-asset communication, because the library can act as a coordinator for data or messages between the assets. A library is typically made to achieve a particular task- where several independent tasks are desired, separate library assets should be created. This allows assets to use only the script code that they require while being isolated from any unrelated script code.

The simplest way to reference a particular library from an asset script is to use the "script-include-table" tag in that asset's config.txt file. This causes the asset to become dependant on the library, and makes it possible to directly include the library's scripts from the asset's script file(s). The asset may use World.GetLibrary() to get a reference to the library, as demonstrated here.

Downloads

Attach sample files here?

Categories

Personal tools