Delay code for RotateFunction?
2 posters
Page 1 of 1
Delay code for RotateFunction?
I'm working on trippers for time control signals, but since I'm not so good at .ANIMATED, I can't figure out a functional code that would lay the trip arm down after a certain time which is triggered by trackdistance. (trackdistance because I can't be asked to make a plugin where section lengths can be detected)
First, here's the delay code (extracted from the developer documentation) of the time control signal at 20MPH:
States = Red.csv, Yellow.csv
StateFunction = if[trackDistance>100 | section==0 | section==2, 0, min[value + 0.5*delta/8.94775, 1]]
I need the trip arm to work the same way, however since it's a RotateFunction (the trip arm rotates down by -0.7 from 0), the "min" function makes the trip arm to rotate infinitely. I tried other alternatives but no success at all.
Is there an alternative I can use other than the "min" function for a delay? I need the trip arm to rotate down by -0.7 from 0, 8.94775 seconds after the train is 100 meters away from the tripper. Preferably as a condition that I can include here: if[trackDistance>100 | section==0 | section==2, 0, ..........]
I will delete the post if I figure it out, but if it's still here, feel free to help.
Thanks
First, here's the delay code (extracted from the developer documentation) of the time control signal at 20MPH:
States = Red.csv, Yellow.csv
StateFunction = if[trackDistance>100 | section==0 | section==2, 0, min[value + 0.5*delta/8.94775, 1]]
I need the trip arm to work the same way, however since it's a RotateFunction (the trip arm rotates down by -0.7 from 0), the "min" function makes the trip arm to rotate infinitely. I tried other alternatives but no success at all.
Is there an alternative I can use other than the "min" function for a delay? I need the trip arm to rotate down by -0.7 from 0, 8.94775 seconds after the train is 100 meters away from the tripper. Preferably as a condition that I can include here: if[trackDistance>100 | section==0 | section==2, 0, ..........]
I will delete the post if I figure it out, but if it's still here, feel free to help.
Thanks
1969 St. Louis R-40M- Posts : 33
Join date : 2020-02-07
Rakago likes this post
Re: Delay code for RotateFunction?
Let's look at this logically
Your important code is this:
min[value + 0.5*delta/8.94775, 1]
It does the following:
Returns the *minimum* of the last function result (value) PLUS
05 * the elapsed time (delta) divided by 8.94775
OR 1
So, it'll therefore count up to one, and then stop.
The state function rounds this, so it'll only display states 0 and one
You're trying to get this to work in a rotation function, which is a little more involved, and will require a statefunction too. (As the rotation function doesn't round)
Fortunately, your statefunction is *identical* to the one you've got above
Our rotate function is simplicity itself- It just needs a quick state check:
Putting this together:
http://web.archive.org/web/20100902041536/http://openbve.freeforums.org/delay-in-approach-controlled-signals-t1195.html#p5378
Your important code is this:
min[value + 0.5*delta/8.94775, 1]
It does the following:
Returns the *minimum* of the last function result (value) PLUS
05 * the elapsed time (delta) divided by 8.94775
OR 1
So, it'll therefore count up to one, and then stop.
The state function rounds this, so it'll only display states 0 and one
You're trying to get this to work in a rotation function, which is a little more involved, and will require a statefunction too. (As the rotation function doesn't round)
Fortunately, your statefunction is *identical* to the one you've got above
Our rotate function is simplicity itself- It just needs a quick state check:
- Code:
RotateYFunction = if[currentState == 0, 0, -0.7]
Putting this together:
- Code:
States = SignalArm.csv, SignalArm.csv
StateFunction = if[trackDistance>100 | section==0 | section==2, 0, min[value + 0.5*delta/8.94775, 1]]
RotateYFunction = if[currentState == 0, 0, -0.7]
http://web.archive.org/web/20100902041536/http://openbve.freeforums.org/delay-in-approach-controlled-signals-t1195.html#p5378
Gothpaladinus and 1969 St. Louis R-40M like this post
Re: Delay code for RotateFunction?
I can't thank you enough! I've been trying different things for more than a hour, while ripping my hair off!
Turns out the solution was very simple.
With the addition of RotateXDamping, it works just like I wanted.
Thanks again!
Turns out the solution was very simple.
With the addition of RotateXDamping, it works just like I wanted.
Thanks again!
1969 St. Louis R-40M- Posts : 33
Join date : 2020-02-07
Gothpaladinus likes this post
Re: Delay code for RotateFunction?
No problem
I've added this example to the documentation, and fixed the link so that it shows the archive page.
I've added this example to the documentation, and fixed the link so that it shows the archive page.
Gothpaladinus and Midnight Express Ginga81 like this post
Similar topics
» Building a Route Based on the Staten Island Railway Integrated into the NYC Subway System (Download Update 10/24/2023)
» Portal code modification
» Animation code - assistance needed
» Portal code modification
» Animation code - assistance needed
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|