Junction Kit

From TrainzOnline
Revision as of 06:35, 25 April 2013 by Andi06 (Talk | contribs)

Jump to: navigation, search

Contents

Notes on the Preview Assets

Default Control

By default clicking on a fixed track junction asset will only toggle the first referenced switch, usually item 0 in the junction-vertices table. There is no way that the other nodes can be manually switched without script. However the AI will be able to successfully negotiate the object no matter how many junction-vertices are defined.

The assets do not respond to the junction-direction button on the track tab in Surveyor and they cannot be switched on the minimap.

These drawbacks can only be addressed by Auran.

Script Library Control

There is a button in the Properties dialogue which allows you to toggle through all of the possible settings to set a new default for the session. These settings are remembered across session saves.

In Driver the AI is left to its own devices and should be able to switch the junctions properly without interference from the script.

Pressing J or ^J from a train will toggle the node nearest to the train and will set up any other junction nodes to suit.

Clicking on the mesh will toggle to the next available state.

It is not possible to detect the difference between a mouse click on the mesh and a keypress from a train approaching the first node with 100% accuracy.

Keypresses from a train or mouse clicks will toggle junctions unconditionally (even if under another train) this is no different from the behaviour of spline junctions.

Known Issue

Any of the original junction kit assets will throw a script exception whenever a new style fixed-track junction is toggled. This doen't affect the operation of either type of asset and requires a simple modification to the original object scripts which I will update when time permits.

Levers

Levers are entirely decorative, the junctions are activated by a click on the main mesh. I expect that it will be possible to allow for levers to be separate attached animations.

Junction Linking

This is experimental. To avoid recursive loops the links are one way only, so to set up a single track crossover for instance you will need to add a link to both junctions. Links are ignored by the AI - they only operate when the junctions are manually switched.

Asset Configuration

config.txt: Tags & Containers

  • This is a list of tags and containers which relate to fixed track junctions.
  • Tags in bold type are essential for correct operation of the Library.
Tag Value Description
kind fixedtrack This is mandatory, fixed junctions will not work as any other asset kind.
use-named-track 1 This tag enables messages to be generated for scenery triggers attached to the junctions
use-gradient-track 1 This affects the way that TRS handles height adjustments.
rotate-yz-range -10,10 Allows junctions to be rolled to align with a grade. This is optional but if you wish to implement it you will need to align your models along the X axis in GMax, horizontally on the 'page'
rollstep 0.1 Defines the minimum angular increment when junctions are rolled.
script-include-table {
   0
}
<kuid:122285:79000>
This is a pointer to the asset containing the script referenced by JKObject.gs.
script "JKObject" The script file which you should drop into your asset folder
class "JKObject" The name of the script class within this file
kuid-table {

   codelib
}

<kuid:122285:79000>
codelib is the script library.
extensions {

   jk2-122285 {
      junction-type
      default-state
   }
}

 

 
integer
integer
 
 

junction-type (see below) defines the layout and behaviour of the junction.

default-state (see below) defines the initial direction of the junction when first placed in Surveyor, this defaults to 0 if the tag is not present. The state can always be altered via the object property interface.


junction-type codes

  • A correct entry for this tag in the extensions table is essential for the script to recognise what actions need to be taken in response to conditions encountered.
  • The sub-table should remain as jk2-122285, do not alter it to your own kuid.
Value Description
0 Fixed track object with no animations, typically this would be a spacer which has no animations but which which needs scripted ability (such as ballast hiding) to match other assets.
1 Diamond crossing
2 Catch point (Derail)
3 Two way point
4 Three way point
5 Single slip
6 Double slip
7 Double crossover
  Other types may be defined and added to this list as the project progresses.

default-state codes

  • These are not always the same as the junction direction constants defined in TRS.
  • For multi junction objects, to allow the script to understand which node is which they must be defined in config.txt in the same order as set out in the diagrams below.
junction-type Legal Values
0 Not relevant
1 To be developed
2 0 = left
1 = right
3 0 = left
1 = right
4 0 = left
1 = centre
2 = right
5 SingleSlip.jpg
6 DoubleSlip.jpg
7 DoubleCrossover.jpg


mesh table containers

  • The library deals with animations and hiding of meshes based on the mesh names.
  • The actual content of the mesh containers is of no relevance to the script except where noted below.
  • The following special names are recognised.
  • Additional special mesh names will be added as the project develops.
Mesh Name Script Action
template# These are marker meshes which can be used for alignment or simply to indicate the location of node 1. You can provide any number of thesem starting with template1, template2,...,templaten. As long as there are no breaks in the numeric sequence each mesh will be displayed or hidden as appropriate. These meshes are only ever visible in Surveyor.
blade# These should contain mesh and animation references. Use blade1 for meshes attached to the first node and so on. The library supports both *.im and *.lm meshes.
ballast# If meshes named ballast are supplied they can be hidden via a property object option. Again you can serialise the containers to have the script act on more than one mesh.
Personal tools