KIND Library

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m
(Supported Tags)
 
(2 intermediate revisions by one user not shown)
Line 14: Line 14:
 
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.
  
kind                           "library"
+
  kind                             "library"
always-load-in-global-context 0
+
  always-load-in-global-context   0
controlset                     NULLKUID
+
  controlset                       NULLKUID
tni-library-name               ""
+
  soundscript                      { }
 
+
  tni-library-name                 ""
 +
  tni-socket-templates            { }
  
 
====always-load-in-global-context====
 
====always-load-in-global-context====
Line 26: Line 27:
 
:Type: KUID
 
:Type: KUID
 
:Desc: Specifies a [[KIND Controlset|controlset]] asset to link to this library.
 
:Desc: Specifies a [[KIND Controlset|controlset]] asset to link to this library.
 +
====soundscript====
 +
:Type: [["Soundscript" container|Soundscript Container]]
 +
:Desc: Specifies a list of sounds which the library may play from script.
 
====tni-library-name====
 
====tni-library-name====
 
:Type: string
 
:Type: string
 
:Desc: Specifies a filename for a [[TrainzNativeInterface]] plugin DLL associated with this asset.
 
:Desc: Specifies a filename for a [[TrainzNativeInterface]] plugin DLL associated with this asset.
 +
====tni-socket-templates====
 +
:Type: [[socket-template-list Container]]
 +
:Desc: Specifies a list of socket templates for use within TNISocket calls.
  
 
==Example Config.txt==
 
==Example Config.txt==
 
Sample [[config.txt file]] for a library asset, with the Standard Tags excluded for brevity:
 
Sample [[config.txt file]] for a library asset, with the Standard Tags excluded for brevity:
  
kind   "library"
+
   kind                            "library"
script "LibraryScript.gs"
+
  script                           "LibraryScript.gs"
class "LibraryClass"
+
  class                           "LibraryClass"
  
 
==Downloads==
 
==Downloads==

Latest revision as of 09:41, 12 December 2017

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.

Contents

[edit] KIND Hierarchy

[edit] Parent Classes

[edit] Child Classes

[edit] 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    0
 controlset                       NULLKUID
 soundscript                      { }
 tni-library-name                 ""
 tni-socket-templates             { }

[edit] always-load-in-global-context

Type: bool
Desc: If true, this library is always loaded to the global script context.

[edit] controlset

Type: KUID
Desc: Specifies a controlset asset to link to this library.

[edit] soundscript

Type: Soundscript Container
Desc: Specifies a list of sounds which the library may play from script.

[edit] tni-library-name

Type: string
Desc: Specifies a filename for a TrainzNativeInterface plugin DLL associated with this asset.

[edit] tni-socket-templates

Type: socket-template-list Container
Desc: Specifies a list of socket templates for use within TNISocket calls.

[edit] 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"

[edit] Downloads

Attach sample files here?

[edit] Categories

Personal tools