SetSignalState AUTOMATIC not working

VVMM

Trainz Scripter/Developer
Hi!

I am writing my own signaling script and using
SetSignalState(null, RED, "stop there");
to force a signal to be RED and
SetSignalState(null, AUTOMATIC, "");
to revert to Trainz's decision.

But setting to AUTOMATIC does NOT make the signal green again. It remains RED forever.

Is this a bug?

I am using Trainz 22 SP6.
 
found in signal.gs:
C++:
// ============================================================================
// Desc: Basic signal states. AI driver behaviour is mostly defined in terms
//       of these simple states.
// ============================================================================
  public define int GREEN = 2;       // Signal is green (clear state).
  public define int YELLOW = 1;      // Signal is yellow (caution state).
  public define int RED = 0;         // Signal is red (stop state).
  public define int AUTOMATIC = -1;  // Signal state is automatically handled by %Trainz.

C++:
SetSignalState(null, Signal.AUTOMATIC, "");

works just as it should. My guess is that by not referencing Signal that it just always inserts a 0 there making it red all the time.
 
Thanks for reply. Have you tested it yourself? There is no difference between Signal.AUTOMATIC and AUTOMATIC, as I have included signal.gs.

I also tried like this:
C++:
SetSignalState(null, Signal.AUTOMATIC, "");
Soup signalStateSoup = DetermineUpdatedState();
ApplyUpdatedState(signalStateSoup);
ForceUpdate();

But the signal still remains RED and I get SPAD warning while driving, so it is indeed RED. Although the ToolTip shows 8 - Line ahead is clear.

I printed
Interface.Log(GetLocalisedName() + " : AUTO is_automatic? " + IsSignalStateAutomatic());
and it shows that YES, it IS automatic, but RED ...

But If I force it GREEN or YELLOW, it works, just not AUTOMATIC...
 
Last edited:
I can't speak for the other parts of your set-up but yes this works as intended where I use it. I do not even need to force any updates because that should all come automatically by the setting.

C-like:
signal.SetSignalState(null, Signal.AUTOMATIC, "");

snipped directly out of my code from an object I am just about to upload to the DLS.

Are you sure you are applying it on the signal you intend?
 
Back
Top