Class MapObject

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (PlaySoundScriptEvent)
m (Change link to library reference, not language reference)
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
*[[TrainzScript Language Reference|API Hierarchy]]
+
*[[TrainzScript Library Reference|API Hierarchy]]
 
**[[Class GSObject|GSObject]]
 
**[[Class GSObject|GSObject]]
 
***[[Class GameObject|GameObject]]
 
***[[Class GameObject|GameObject]]
Line 26: Line 26:
  
 
==Methods==
 
==Methods==
 +
<br>
 +
===AdjustMapObjectPosition===
 +
{{MethodHeader|public native void AdjustMapObjectPosition(float dx, float dy, float dz)}}
 +
;Parameters
 +
*'''dx''' = The distance (m) to move the object along its x axis (right).
 +
*'''dy''' = The distance (m) to move the object along its y axis (foward).
 +
*'''dz''' = The distance (m) to move the object along its z axis (upward).
 +
;Returned Value
 +
* None.
 +
;Syntax
 +
AdjustMapObjectPosition(x, y, z);
 +
;Notes
 +
<br>
 +
 +
===GetMapObjectOrientation===
 +
{{MethodHeader|public native Orientation GetMapObjectOrientation(void)}}
 +
;Parameters
 +
* None.
 +
;Returned Value
 +
*The absolute orientation of this MapObject.
 +
;Syntax
 +
float angel_z = cabin.Loco.GetMapObjectOrientation().rz;
 +
;Notes
 +
* A call to GetMapObjectOrientation() which immediately follows a call to SetMapObjectOrientation() is not guaranteed to return the input orientation, since various other orientation restrictions may be in effect.
 +
<br>
 +
 +
===GetMapObjectPosition===
 +
{{MethodHeader|public native Orientation GetMapObjectPosition(void)}}
 +
;Parameters
 +
* None.
 +
;Returned Value
 +
*The absolute position of this MapObject.
 +
;Syntax
 +
float axis_z = cabin.Loco.GetMapObjectPosition().z;
 +
;Notes
 +
* A call to GetMapObjectPosition() which immediately follows a call to SetMapObjectPosition() is not guaranteed to return the input position, since various other position restrictions may be in effect.
 
<br>
 
<br>
  
Line 156: Line 192:
 
*This method will start playing the sound.  
 
*This method will start playing the sound.  
 
*Depending on the SoundScript configuration, the sound will either be played just once or played continuously in a looping cycle such that [[#StopSoundScriptEvent|StopSoundScriptEvent()]] will need to be called to stop it.
 
*Depending on the SoundScript configuration, the sound will either be played just once or played continuously in a looping cycle such that [[#StopSoundScriptEvent|StopSoundScriptEvent()]] will need to be called to stop it.
 +
<br>
 +
 +
===SetMapObjectOrientation===
 +
{{MethodHeader|public native void SetMapObjectOrientation(Orientation orientation)}}
 +
;Parameters
 +
*'''orientation''' =  The new orientation intended for this MapObject.
 +
;Returned Value
 +
*None
 +
;Syntax
 +
SetMapObjectOrientation(or);
 +
;Notes
 +
*Instantly reorients this MapObject to the specified absolute orientation, as best possible. This will not successfully reposition a MapObject which has a parent relationship (for example, a Trackside object.) Various object parameters and game states may restrict or remove the ability to reorient objects.
 +
<br>
 +
 +
===SetMapObjectPosition===
 +
{{MethodHeader|public native void SetMapObjectPosition(WorldCoordinate position)}}
 +
;Parameters
 +
*'''position''' =  The new position intended for this MapObject.
 +
;Returned Value
 +
*None
 +
;Syntax
 +
SetMapObjectPosition(pos);
 +
;Notes
 +
*Instantly repositions this MapObject to the specified absolute position, as best possible. This will not successfully reposition a MapObject which has a parent relationship (for example, a Trackside object.) This function may be VERY slow and should generally not be used. Various object parameters and game states may restrict or remove the ability to position objects.
 
<br>
 
<br>
  
Line 188: Line 248:
 
*'''id''' = The ID of the particle effect, starting at zero and in the order defined in ''config.txt''.
 
*'''id''' = The ID of the particle effect, starting at zero and in the order defined in ''config.txt''.
 
*'''phase''' = The phase of the effect, if there is only one phase use zero.
 
*'''phase''' = The phase of the effect, if there is only one phase use zero.
*'''r,g,b''' = Red, green and blue components of the required colour.
+
*'''r,g,b''' = Red, green and blue components of the required color.
*'''a''' = Alpha value of the colour.
+
*'''a''' = Alpha value of the color.
 
;Returned Value
 
;Returned Value
 
*None
 
*None
Line 295: Line 355:
 
*'''id''' = The ID of the particle effect, starting at zero and in the order defined in ''config.txt''.
 
*'''id''' = The ID of the particle effect, starting at zero and in the order defined in ''config.txt''.
 
*'''phase''' = The phase of the effect, if there is only one phase use zero.
 
*'''phase''' = The phase of the effect, if there is only one phase use zero.
*'''r,g,b''' = Red, green and blue components of the required colour.
+
*'''r,g,b''' = Red, green and blue components of the required color.
*'''a''' = Alpha value of the colour.
+
*'''a''' = Alpha value of the color.
 
;Returned Value
 
;Returned Value
 
*None
 
*None

Latest revision as of 23:46, 28 December 2020


  • This class extends MeshObject to include product queues.
  • A MapObject can have a number of product queues as defined in the queues section of the config.txt file for the asset.
  • The class also provides methods to control particle emissions.


Contents

[edit] MapObject Messages


Major Minor Source Destination
MapObject View-Details ? MapObject
MapObject View-Schedule ? MapObject


[edit] Methods


[edit] AdjustMapObjectPosition

public native void AdjustMapObjectPosition(float dx, float dy, float dz)
Parameters
  • dx = The distance (m) to move the object along its x axis (right).
  • dy = The distance (m) to move the object along its y axis (foward).
  • dz = The distance (m) to move the object along its z axis (upward).
Returned Value
  • None.
Syntax
AdjustMapObjectPosition(x, y, z);
Notes


[edit] GetMapObjectOrientation

public native Orientation GetMapObjectOrientation(void)
Parameters
  • None.
Returned Value
  • The absolute orientation of this MapObject.
Syntax
float angel_z = cabin.Loco.GetMapObjectOrientation().rz;
Notes
  • A call to GetMapObjectOrientation() which immediately follows a call to SetMapObjectOrientation() is not guaranteed to return the input orientation, since various other orientation restrictions may be in effect.


[edit] GetMapObjectPosition

public native Orientation GetMapObjectPosition(void)
Parameters
  • None.
Returned Value
  • The absolute position of this MapObject.
Syntax
float axis_z = cabin.Loco.GetMapObjectPosition().z;
Notes
  • A call to GetMapObjectPosition() which immediately follows a call to SetMapObjectPosition() is not guaranteed to return the input position, since various other position restrictions may be in effect.


[edit] GetPFXEmitterLifetime

public native float GetPFXEmitterLifetime(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Value of the lifetime of the effect at the specified phase.
Syntax
float lifetime GetPFXEmitterLifetime(0,0);
Notes


[edit] GetPFXEmitterMaxRate

public native float GetPFXEmitterMaxRate(int id)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
Returned Value
  • Maximum rate of emissions per second.
Syntax
float maxRate = GetPFXEmitterMaxRate(0);
Notes


[edit] GetPFXEmitterMaxSize

public native float GetPFXEmitterMaxSize(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Maximum size of particle at the specified phase.
Syntax
float maxsize = GetPFXEmitterMinSize();
Notes


[edit] GetPFXEmitterMinRate

public native float GetPFXEmitterMinRate(int id)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
Returned Value
  • Maximum rate of emissions per second.
Syntax
float minRtae = GetPFXEmitterMinRate(0);
Notes


[edit] GetPFXEmitterMinSize

public native float GetPFXEmitterMinSize(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Minimum size of particle at the specified phase.
Syntax
float minsize = GetPFXEmitterMinSize();
Notes


[edit] GetPFXEmitterPhysicsDelay

public native float GetPFXEmitterPhysicsDelay(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Value for the physics delay in emission.
Syntax
GetPFXEmitterPhysicsDelay(0,0);
Notes


[edit] GetPFXEmitterRate

public native float GetPFXEmitterRate(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Rate of particle creation per second.
Syntax
particlesPerSecond = GetPFXEmitterRate(0,0);
Notes


[edit] GetPFXEmitterVelocity

public native float GetPFXEmitterVelocity(int id, int phase)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
Returned Value
  • Velocity in metres per second along the direction vector of emitted particles at the specified phase.
Syntax
float speed = GetPFXEmitterVelocity(0,0);
Notes


[edit] GetQueue

public native ProductQueue GetQueue(string queueName)
Parameters

queueName = Name of the product queue to be returned.

Returned Value
  • A reference to the queue if possible, null otherwise.
Syntax
ProductQueue queue = GetQueue("passengers");


[edit] GetQueues

public native ProductQueue[ ] GetQueues(void)
Parameters
  • None
Returned Value
  • An array of product queues, if there are no queues the array will be empty.
Syntax
ProductQueue[] queues = GetQueues();


[edit] PlaySoundScriptEvent

public native void PlaySoundScriptEvent(string soundTrigger)
Parameters

soundTrigger = Name of the sound event to start playing, this equates to the trigger tag of the sound script subcontainer in config.txt.

Returned Value
  • None
Syntax
PlaySoundScriptEvent("dayloop");
Notes
  • Plays the specified sound event from the asset's SoundScript.
  • SoundScripts are defined as sub-containers in the soundscript container of the asset's configuration.
  • For details on creating assets with SoundScripts, see here.
  • This method will start playing the sound.
  • Depending on the SoundScript configuration, the sound will either be played just once or played continuously in a looping cycle such that StopSoundScriptEvent() will need to be called to stop it.


[edit] SetMapObjectOrientation

public native void SetMapObjectOrientation(Orientation orientation)
Parameters
  • orientation = The new orientation intended for this MapObject.
Returned Value
  • None
Syntax
SetMapObjectOrientation(or);
Notes
  • Instantly reorients this MapObject to the specified absolute orientation, as best possible. This will not successfully reposition a MapObject which has a parent relationship (for example, a Trackside object.) Various object parameters and game states may restrict or remove the ability to reorient objects.


[edit] SetMapObjectPosition

public native void SetMapObjectPosition(WorldCoordinate position)
Parameters
  • position = The new position intended for this MapObject.
Returned Value
  • None
Syntax
SetMapObjectPosition(pos);
Notes
  • Instantly repositions this MapObject to the specified absolute position, as best possible. This will not successfully reposition a MapObject which has a parent relationship (for example, a Trackside object.) This function may be VERY slow and should generally not be used. Various object parameters and game states may restrict or remove the ability to position objects.


[edit] SetPFXEmitterConeSize

public native void SetPFXEmitterConeSize(int id, float x, float y, float z)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • x,y,z = New X,Y and Z components of the particle cone size.
Returned Value
  • None
Syntax
SetPFXEmitterConeSize(0,2.0,3.0,2.0);
Notes


[edit] SetPFXEmitterEmitParticles

public native void SetPFXEmitterEmitParticles(int id, int number,float time)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • number = The number of particles to emit.
  • time = The time in seconds over which the particles are to be created.
Returned Value
  • None
Syntax
SetPFXEmitterEmitParticles(0,100,10.0);
Notes


[edit] SetPFXEmitterEndColor

public native void SetPFXEmitterEndColor(int id, int phase, float r, float g, float b, float a)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • r,g,b = Red, green and blue components of the required color.
  • a = Alpha value of the color.
Returned Value
  • None
Syntax
SetPFXEmitterStartColor(0,0,128,128,128,64);
SetPFXEmitterStartColor(0,0,0.5,0.5,0.5,0.25);
Notes
  • Red, green, blue and alpha may be entered as integer or float values in the ranges 0..255 and 0.0..1.0 respectively.
  • Both of the examples above give the same result.
  • Note that 1,1,1,1 will be interpreted as float input and will produce white, whereas 2,2,2,2 will be interpreted as integers and will give a result which is almost black.


[edit] SetPFXEmitterLifetime

public native void SetPFXEmitterLifetime(int id, int phase, float life)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • life = The new lifetime of particles in seconds at the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterLifetime(0,0,10);
Notes


[edit] SetPFXEmitterMaxRate

public native void SetPFXEmitterMaxRate(int id, float newsize)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • rate = The new maximum rate of emission per second.
Returned Value
  • None
Syntax
SetPFXEmitterMaxRate(0,5.0);
Notes


[edit] SetPFXEmitterMaxSize

public native void SetPFXEmitterMaxSize(int id, int phase, float newsize)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • newsize = The new maximum size of particles at the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterMaxSize(0,0,10);
Notes


[edit] SetPFXEmitterMinRate

public native void SetPFXEmitterMinRate(int id, float rate)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • rate = The new minimum rate of emission per second.
Returned Value
  • None
Syntax
SetPFXEmitterMinRate(0,5.0);
Notes


[edit] SetPFXEmitterMinSize

public native void SetPFXEmitterMinSize(int id, int phase, float newsize)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • newsize = The new minimum size of particles at the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterMinSize(0,0,10);
Notes


[edit] SetPFXEmitterPhysicsDelay

public native void SetPFXEmitterPhysicsDelay(int id, int phase, float value)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • value = The new physics delay value to set for the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterPhysicsDelay(0,0,5.0);
Notes


[edit] SetPFXEmitterRate

public native void SetPFXEmitterRate(int id, int phase, float rate)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • rate = New rate of particle creation per second at the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterRate(0,0,5.0);
Notes


[edit] SetPFXEmitterStartColor

public native void SetPFXEmitterStartColor(int id, int phase, float r, float g, float b, float a)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • r,g,b = Red, green and blue components of the required color.
  • a = Alpha value of the color.
Returned Value
  • None
Syntax
SetPFXEmitterStartColor(0,0,128,128,128,64);
SetPFXEmitterStartColor(0,0,0.5,0.5,0.5,0.25);
Notes
  • Red, green, blue and alpha may be entered as integer or float values in the ranges 0..255 and 0.0..1.0 respectively.
  • Both of the examples above give the same result.
  • Note that 1,1,1,1 will be interpreted as float input and will produce white, whereas 2,2,2,2 will be interpreted as integers and will give a result which is almost black.


[edit] SetPFXEmitterTexture

public native void SetPFXEmitterTexture(int id, KUID textureKUID)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • textureKUID = The kuid of the new texture.
Returned Value
  • None
Syntax
SetPFXEmitterTexture(0,<kuid:1234:5678>);
Notes


[edit] SetPFXEmitterVelocity

public native void SetPFXEmitterVelocity(int id, int phase, float velocity)
Parameters
  • id = The ID of the particle effect, starting at zero and in the order defined in config.txt.
  • phase = The phase of the effect, if there is only one phase use zero.
  • velocity = New velocity in metres per second along the direction vector of emitted particles at the specified phase.
Returned Value
  • None
Syntax
SetPFXEmitterVelocity(0,0,5.0);
Notes


[edit] StopSoundScriptEvent

public native void StopSoundScriptEvent(string soundTrigger)
Parameters

soundTrigger = Name of the sound event to start playing, this equates to the trigger tag of the sound script subcontainer in config.txt.

Returned Value
  • None
Syntax
StopSoundScriptEvent("dayloop");
Notes


[edit] Related Methods

[edit] Categories

Personal tools