New State Logic


From Build #107.1, a new state logic for signals has been implemented.

The previous state control (see http://www.markhodson.nl/2kdhelp/446.htm) has been found to be unsatisfactory with some more complex signal types. It can still be used, but a new syntax, based on Rail3D scripting can now be used instead (as well).



Instead of providing a state table, you may now write script code to set a lamp colour.

For example:


would set the lamp to red (255.0.0) if the signal is On (State ‘S’ - stop), or to black (off) otherwise.



The new code uses exactly the same scripting as the main Rail3D scripting engine (see Signal for details of scripting of signals. The only changes are:

  • State setting code is added to a lamp inside a pair of braces
  • State setting code is called as for the OnSetLamps() function (see Signal)
  • Lamps must have a lamp id defined to use the new code
  • Some shorthand is allowed in the lamp code block, for example #S is a shorthand for the signal being on. The full list of substitutions is given below.


To simplify the code in a signal lamp block, and hopefully draw the comparison with the older state tables, some script functions may be written in a shorthand. Thus the example given above is the shorthand version of:


where ‘id’ is the id of the signal lamp.

The full list of shorthand substitutions is:

#S IsOn()
#C IsCau()
#C2 IsCau2()
#J IsJct()
#J2 IsJct2()
#H IsShunt()
#L IsClear()
#Colour SetLamp(id,


MRG 05/06/2013 12:10:27