Scripting to get the time waiting at a platform?
Moderator: Moderators
- chrisell
- Well Established Forum Member
- Posts: 533
- Joined: Mon May 06, 2002 12:00 am
- Location: England, Holland and America
- Contact:
Scripting to get the time waiting at a platform?
Anyone know if there's a LUA function to get the duration of a stop in a scenario where the train is waiting at a platform? My door-closing bell is hard-coded to 20 seconds in all my trains but it would be nice if I could query the scenario and find out exactly how long we'll be sitting at a platform.
Chris L
http://www.christrains.com
http://www.christrains.com
- Irishrailguy
- Very Active Forum Member
- Posts: 1338
- Joined: Sun Mar 21, 2010 8:58 pm
- Location: Dublin, Ireland
Re: Scripting to get the time waiting at a platform?
Are you looking to get the time at the platform with the doors open? Or just the amount of time remaining stationary at the platform? The latter is probably impossible as there'd be no way to tell whether you've stopped beside a platform or are just stopped at an arbitrary location. The former should be relatively easy though, just invoke a timer in your Update() function to start whenever either of the DoorsOpenClose controls change to the on position, then reset the timer after they close again and you've stored that time somewhere.
Kev
Kev
Re: Scripting to get the time waiting at a platform?
There is no way to request these informations from plattforms or other things. So what is the point of doing this? If you want the bell sounds when the passenger boardings are done, just detach the door animations from the door controllers, lets bell the bell when the door controller jumps to 0 and then animate the doors by script (open and close), like vR does
Better you control everything from script, also the door bells (SoundBla:SetParameter, "bla", {int}).
- chrisell
- Well Established Forum Member
- Posts: 533
- Joined: Mon May 06, 2002 12:00 am
- Location: England, Holland and America
- Contact:
Re: Scripting to get the time waiting at a platform?
I've tried doing this but it results in the AI trains leaving with the doors still open. Why? The AI trains leave within a second of the controller changing to 0.MaikG wrote:There is no way to request these informations from plattforms or other things. So what is the point of doing this? If you want the bell sounds when the passenger boardings are done, just detach the door animations from the door controllers, lets bell the bell when the door controller jumps to 0 and then animate the doors by script (open and close), like vR doesBetter you control everything from script, also the door bells (SoundBla:SetParameter, "bla", {int}).
So if I trip the bell sound when the controller goes to 0, then wait 5 to 6 seconds, then run the animations. But that means the AI trains sound the bell, then leave the station, and 5 seconds later the doors close.
Did you find a way to stop the AI trains from leaving straight away or do you just live with open doors while the train is moving?
Chris L
http://www.christrains.com
http://www.christrains.com
- AndiS
- Very Active Forum Member
- Posts: 6207
- Joined: Fri Sep 23, 2005 4:43 pm
- Location: Jester's cell in ivory tower
- Contact:
Re: Scripting to get the time waiting at a platform?
For distinguishing AI from player, there is GetIsPlayer. For AI, you might have some luck using Kevin's idea, starting the closing procedure some 15 seconds after door opening if the fixed duration be 20 seconds.
I must say I have zero experience with AI doors, I only know that AI do the same thing - dashing away at the start of an animation - at switches.
Whoever publishes a working method of slamming down the throttle in unruly AI trains wins the Nobel Prize in Train Simulation.
I must say I have zero experience with AI doors, I only know that AI do the same thing - dashing away at the start of an animation - at switches.
Whoever publishes a working method of slamming down the throttle in unruly AI trains wins the Nobel Prize in Train Simulation.
- chrisell
- Well Established Forum Member
- Posts: 533
- Joined: Mon May 06, 2002 12:00 am
- Location: England, Holland and America
- Contact:
Re: Scripting to get the time waiting at a platform?
For the standard waiting time, (20 seconds) it's not a problem. I can run a timer to play the door chime when I want. The problem comes when making timetabled scenarios where you want the player to sit at a platform for a minute (for example). The door chime plays after 15 seconds but then the doors stay open for the full minute. Same for AI trains - if you make them stop at a platform for 40 seconds (for example) the chime sounds after 15 seconds but the doors close at 40 seconds.
A simple Call("Scenariomanager:WaitTime",0) would be awesome if it existed
A simple Call("Scenariomanager:WaitTime",0) would be awesome if it existed
Chris L
http://www.christrains.com
http://www.christrains.com
Re: Scripting to get the time waiting at a platform?
The whole thing is a bit more complex with AI. I have a switch in each wagon script. It switches between player controlled consist and AI controlled, and if AI controlled then there is no delay: bell sounds and doors are closing at same time and a bit faster. The switch self is controlled by the loco (the driven vehicle in most situations). The loco sends a message every 10 sec along the consist and the wagons then switching to player controlled and store this state. If you decouple the switch will release back to AI driven state after 20sec because no loco message comes in anymore. That is the only way to control the two cases of player and AI driven consists in wagons. GetIsPlayer does not work in AI driven consists, and often not in player driven consists. So that is not an option.
- chrisell
- Well Established Forum Member
- Posts: 533
- Joined: Mon May 06, 2002 12:00 am
- Location: England, Holland and America
- Contact:
Re: Scripting to get the time waiting at a platform?
Yeah - I've found GetIsPlayer isn't reliable. I like your solution though - that's neat. I might give that a try. Thanks for the tipMaikG wrote:The whole thing is a bit more complex with AI. I have a switch in each wagon script. It switches between player controlled consist and AI controlled, and if AI controlled then there is no delay: bell sounds and doors are closing at same time and a bit faster. The switch self is controlled by the loco (the driven vehicle in most situations). The loco sends a message every 10 sec along the consist and the wagons then switching to player controlled and store this state. If you decouple the switch will release back to AI driven state after 20sec because no loco message comes in anymore. That is the only way to control the two cases of player and AI driven consists in wagons. GetIsPlayer does not work in AI driven consists, and often not in player driven consists. So that is not an option.
FYI this is the train I'm putting the finishing touches on ...

To view the video, click on the PLAY button.
If you click anywhere else on this video, you will be taken to a YouTube page, where you may find yourself subjected to content that you feel is offensive.
If you feel THIS video is inappropriate, please report it to a moderator immediately for prompt action.
Chris L
http://www.christrains.com
http://www.christrains.com
-
Anthony061
- Established Forum Member
- Posts: 319
- Joined: Sun Dec 30, 2012 12:21 pm
- Location: Cardiff
Re: Scripting to get the time waiting at a platform?
Looking good!! Nice to see the variety you've got therechrisell wrote:FYI this is the train I'm putting the finishing touches on ...The sounds for the wheels and flanges have changed during beta test since this video.
This video is hosted by YouTube, a site which is outside of the editorial control of UKTrainSim and as such Parental Control is strongly advised.
To view the video, click on the PLAY button.
If you click anywhere else on this video, you will be taken to a YouTube page, where you may find yourself subjected to content that you feel is offensive.
If you feel THIS video is inappropriate, please report it to a moderator immediately for prompt action.
Anthony
- chrisell
- Well Established Forum Member
- Posts: 533
- Joined: Mon May 06, 2002 12:00 am
- Location: England, Holland and America
- Contact:
Re: Scripting to get the time waiting at a platform?
I am trying to get SBB to grant me a license to do the Thurbo version for Switzerland but that's slow going right now so it might not happen until the v1.1 patch - whenever that is. I'm also looking at the Ostdeutsche Eisenbahn (ODEG) version but I'd need to write PZB for that, in addition to getting the license.Anthony061 wrote:Looking good!! Nice to see the variety you've got therechrisell wrote:FYI this is the train I'm putting the finishing touches on ...The sounds for the wheels and flanges have changed during beta test since this video.
This video is hosted by YouTube, a site which is outside of the editorial control of UKTrainSim and as such Parental Control is strongly advised.
To view the video, click on the PLAY button.
If you click anywhere else on this video, you will be taken to a YouTube page, where you may find yourself subjected to content that you feel is offensive.
If you feel THIS video is inappropriate, please report it to a moderator immediately for prompt action.May I ask whether we could see a German/Swiss version in future? I noticed you asked about the PZB system a few months back.
Anthony
Chris L
http://www.christrains.com
http://www.christrains.com
-
Anthony061
- Established Forum Member
- Posts: 319
- Joined: Sun Dec 30, 2012 12:21 pm
- Location: Cardiff
Re: Scripting to get the time waiting at a platform?
Thanks for the reply, I look forward to the Thurbo version
Keep up the good work!
Kindest regards,
Anthony
Kindest regards,
Anthony