Named Objects Library

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Named Objects Library : How to use it ?)
(Named Objects Library : How to use it ?)
Line 21: Line 21:
 
To use the Named Object Library in any of your assets, you need first to modify its config.txt file to add the Named Objects Library in its kuid table section and in its script include table so that your asset can reference the Named Objects Library to import the Named Object Library API as a static class nochelper contained in nochelper.gs inside the Named Objects Library Asset.
 
To use the Named Object Library in any of your assets, you need first to modify its config.txt file to add the Named Objects Library in its kuid table section and in its script include table so that your asset can reference the Named Objects Library to import the Named Object Library API as a static class nochelper contained in nochelper.gs inside the Named Objects Library Asset.
  
The current Named Objects Library available on DLS is <kuid2:61392:4053:10> but there will be soon a new release 11 <kuid2:61392:4053:10> that will bring supports for track circuit blocks objects.
+
The current Named Objects Library available on DLS is <kuid2:61392:4053:10> but there will be soon a new release 11 <kuid2:61392:4053:11> that will bring supports for track circuit blocks objects.
  
 
Your asset config.txt file should include the following sections to be able to load the Named Objects Library API as nochelper static class :
 
Your asset config.txt file should include the following sections to be able to load the Named Objects Library API as nochelper static class :

Revision as of 11:26, 15 October 2018

Surveyor's Hotkeys
Driver's Hotkeys
Notations
Glossary

Contents

 


Named Objects Library (SP2 and later)

NamedObjectsLib.jpg



The Named Objects Library is a library that may be used to manage information about available named objects in the current session. The library can manage cached data for several common objects type, which can be individually asynchronously refreshed in the background using threads inside the library, and can return at any time synchronously the content of any of the managed caches.

Usually, an asset using the Named Objects Library will first load and initialize the library in its init routine, will then register the objects type to be cached in the library (which will immediately start the asynchronous process of collecting the cached data for this object type), and will later use the cached data by calling the library to retrieve the current cached data. The library uses all the new object search API available since Tane SP2 and will automaticly refresh in the background any expired cache data. Under surveyor mode, all cached data are refreshed every 3 seconds to include new added objects edited under surveyor ; under driver mode only consists cached data are refreshed every 3 seconds to ensure that consists emited from portals are added to the cached data.


The present article is for scripters who wants to use the Named Objects Library and details below how to configure an asset to use the Named Objects Library, how to initialise in an asset the library and how to register the objects type you want to cache, and finaly how later to retrieve the current content of a cache for a specific object type.

Named Objects Library : How to use it ?

To use the Named Object Library in any of your assets, you need first to modify its config.txt file to add the Named Objects Library in its kuid table section and in its script include table so that your asset can reference the Named Objects Library to import the Named Object Library API as a static class nochelper contained in nochelper.gs inside the Named Objects Library Asset.

The current Named Objects Library available on DLS is <kuid2:61392:4053:10> but there will be soon a new release 11 <kuid2:61392:4053:11> that will bring supports for track circuit blocks objects.

Your asset config.txt file should include the following sections to be able to load the Named Objects Library API as nochelper static class :

            script-include-table
            {
              . . . 
              noclib                                <kuid:61392:4053>
              . . .
            }

and

            kuid-table
            {
               . . .
               noclib                                <kuid2:61392:4053:10>
               . . .
            }

with these two modifications in your asset config.txt file, you should now be able to import the noclib API by adding :

            import "nochelper.gs"

to your assets script files needing to call the noclib API


Personal tools