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.
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 11:33 am
by Irishrailguy
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
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 1:28 pm
by MaikG
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}).
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 2:05 pm
by chrisell
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 does Better you control everything from script, also the door bells (SoundBla:SetParameter, "bla", {int}).
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.
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?
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 2:19 pm
by AndiS
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.
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 2:26 pm
by chrisell
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
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 2:51 pm
by MaikG
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.
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 3:22 pm
by chrisell
MaikG 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.
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 tip
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.
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 5:14 pm
by Anthony061
chrisell 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.
Looking good!! Nice to see the variety you've got there 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
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 5:39 pm
by chrisell
Anthony061 wrote:
chrisell 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.
Looking good!! Nice to see the variety you've got there 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
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.
Re: Scripting to get the time waiting at a platform?
Posted: Wed Oct 29, 2014 6:37 pm
by Anthony061
Thanks for the reply, I look forward to the Thurbo version Keep up the good work!
Kindest regards,
Anthony