Class TrainzGameObject

From TrainzOnline
Revision as of 23:39, 28 December 2020 by Danny252 (Talk | contribs)

Jump to: navigation, search


  • Base class for a GameObject that is an instance of a Trainz asset.
  • This class is a parent class for game objects in the Trainz world that are instances of a Trainz asset.


Init

public void Init(void)
public void Init(Asset asset)
Parameters
  • asset = Reference to the script's associated asset.
Returned Value
  • None
Syntax
  • None, method is automatically called by the game.
Notes
  • Initialisation method which is called by Trainz when the object is first created.
  • It is up to the script programmer to do any initialization tasks required here.
  • This may include starting a thread if the object is to exist in a persistent state.
  • Some derived classes have both an Init() and Init(Asset) method. There isn't much difference between them except one gets the Asset as a parameter. It is recommended that you use the Init(Asset) version whenever you can.
  • When overriding this base Init() method, you must call it explicitly by using the inherited keyword in the overridden implementation.
  • Since Init() is called from native Trainz code, you cannot use Sleep() or wait(). However, Init() can start threaded methods that are allowed to sleep and process messages.


GetAsset

public Asset GetAsset(void)
Parameters
  • None
Returned Value
  • A reference to the current asset
Syntax
Asset asset = GetAsset();
Notes
  • The returned Asset reference can be used to retrieve the KUID, StringTable or configuration data of the Asset.


Categories

Personal tools