That's a fantastic idea, and is exactly what I would have done, if it wasn't for the fact that the locomotive trucks are connected to it's electric motor (these are your typical electric trains, they get power from the two nickel silver rails of the track, theyre not battery powered or anything) with worm gears. :P Sorry, another thing I forgot to mention lol
If the locomotive would coast on it's own I would probably just guesstimate, but I can't guesstimate when the ONLY kind of coasting I can do is simulated because of the way the drive works. It's nice because they never slide down hills or anything, but from a prototypical standpoint its horrible. :P
My current (I know this isn't right, I compared it to the way locomotives handle in RailWorks 2015) system is:
var newLocoSpeedNoBrakes = (((ARGnotch/prototypeMaxNotch) * locoMaxSpeed) / 100)
var newLocoSpeed = newLocoSpeedNoBrakes - (newLocoSpeedNoBrakes * (ARGlocoBrake / 100))
the first line finds the speed in the hypothetical situation that there are no brakes applied, the second one figures out how that changes with the brakes. ARGnotch is the throttle's notch (1-8), and it's divided by prototypeMaxNotch, which is a user configurable variable because some other locomotives have 16 or 22 notches instead of the usual 8. locoMaxSpeed is a configurable setting i put in there so you can get the speed range of it more accurate, because my locomotive's "100% speed" is not really the correct scale speed, it's more on par with breaking the sound barrier lol.
ARGlocoBrake is expressed as a number 0-100, because i use it as a percent.
It SEEMS like it would work, but it's not even remotely close to how RailWorks behaves. If I put the throttle on notch 1 in RailWorks, it doesn't adjust how fast the train ends up going, it adjusts the rate of acceleration mostly. For example notch 1 starts off slow, but after a few minutes I end up going 50mph, and notch 8 starts off MUCH faster and after less time I end up going 50mph. So I assume for notching to be right I'm going to have to have some kind of continuous loop running to constantly recalculate all this, but since JS has no wait function, I don't know how I'm going to do that without crashing the browser with a "black hole" loop.