BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Animated signal: keep it red until the train arrives plus 45 seconds

Go down

Animated signal: keep it red until the train arrives plus 45 seconds Empty Animated signal: keep it red until the train arrives plus 45 seconds

Post by Phonteus Nevolius Mon Mar 23, 2020 1:45 am

I'd like to ask for a bit of help with .animated coding. I have a signal which is right after a passing station. I want to keep it red, because there is an oncoming train. However, I don't seem to be able to do that using normal signals (since it's a passing station, not a stopping one).

Therefore I decided to do this as an animated object. So here is what I have:

- signal.animated including:
- stationary signal pole
- red.b3d for the red light
- green.b3d for the green light

I'd like red.b3d to remain visible until my driveable train is within 200 metres of the signal plus 45 seconds. That is enough time for the oncoming AI train to enter the station. After this time I'd like red.b3d to disappear and green.b3d to appear instead.

Can anyone help me with code for this?
Phonteus Nevolius
Phonteus Nevolius

Posts : 111
Join date : 2017-10-05
Location : Hungary

https://phonteusnevolius.wordpress.com

Back to top Go down

Animated signal: keep it red until the train arrives plus 45 seconds Empty Re: Animated signal: keep it red until the train arrives plus 45 seconds

Post by Phonteus Nevolius Sat Mar 28, 2020 9:48 pm

I've found the solution and I'll post it here in case anyone else searches for this.

The object should be loaded in the With Signal section as a signal and placed in the route using the .SigF command. The function we need is this:

Code:
StateFunction = if[trackDistance>200 | section==0, 0, min[value + 0.5*delta/45, 1]]
Phonteus Nevolius
Phonteus Nevolius

Posts : 111
Join date : 2017-10-05
Location : Hungary

https://phonteusnevolius.wordpress.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum