Web Update 19.10.2024

Script referencing

You are here:
Estimated reading time: 1 min

If we intend to use one script for several models, without having to update the script separately for each model, it is possible to refer to the script using the code to the library where the individual scripts are stored. (This means that one save will affect all other models).

We will create a script that is stored in the library under its own KUID number. For example, we name these files signalext.gs. Then we will create one more script, which will be called emptylib.gs.

Library
config.txt

kind                                    "library"
trainz-build                            3.6
username                                "Signal Core"
author                                  "username"
organization                            "organization"
contact-email                           "@email"
contact-website                         "www"
license                                 "All right reserved by © username"
category-region                         "CH"
category-era                            "1990s"
always-load-in-global-context           0
category-class                          "YR"
script                                  "emptylib.gs"
class                                   "emptylib"

thumbnails
{
  1
  {
    width                               240
    height                              180
    image                               "thumbnail_0.jpg"
  }
}
kuid                                    <kuid:123456:123456>

kuid-table
{
}
emptylib.gs
include "Library.gs"

class emptylib isclass Library {};
signalext.gs
// Signal Extension Script

include "signal.gs"
include "library.gs"
include "trackside.gs"

class SignalExt isclass Signal
{
}

Now we will create a model under a different KUID and we will want, for example, signaling to refer to a script that is stored in the library we created.

We will create a script named exclient.gs.

include "signalext.gs"
class exclient isclass SignalExt {};

Here we explain the calling commands individually:

First line: signalext.gs is a script named and stored in the library
Second line: exclient is a script stored here that calls the SignalExt part in the signalext.gs script

Model configuration file
script-include-table
{
  0                                     <kuid:123456:123456>
}
script                                  "exclient.gs"
class                                   "exclient"
Was this article helpful?
Dislike 0 7 of 7 found this article helpful.
Views: 80
Alpinetrainz
Logo
Shopping cart