KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
697 stars 230 forks source link

WARP does not distinguish between physics and rails mode #8

Closed tsbockman closed 10 years ago

tsbockman commented 10 years ago

A KSP bug

When launching from Kerbin, the time warp mode sometimes remains stuck in physics mode even after leaving the atmosphere and cutting the throttle. I believe this is a bug in the stock game, however when flying manually it is easily worked around by clicking the 1x (normal speed) button manually, causing the game to switch to rails mode if it didn't do so automatically.

KOS script errors

However, KOS seems to be unable to trigger the switch from physics warp to rails warp. As a result, my auto-warping scripts tend to crash a lot with the message,

Array index is out of range.

Which occurs when a script tries to set WARP to a level higher than 3 while in physics mode. (WARP levels 4-7 are only valid when in rails mode.)

Failed scripting solutions

I have inserted gratuitous commands like

set WARP to 0.
WAIT 1.

into my scripts to try and force the game to switch to rails mode if available, but unlike manually clicking the 1x button, this doesn't seem to help when a script does it.

(Strangely, I think it may actually be the act of moving the mouse over the UI which causes the game to recheck if rails warp is available, rather than clicking on the 1x button, specifically.)

Possible KOS solutions

  1. Add settable WARP:MODE property. A setter would allow scripts to force KSP to switch between physics and rails as needed.
  2. Add a readable WARP:MODE property. This would allow scripts to adjust their behavior to avoid trying to set WARP >= 4 when in physics mode.
  3. Add a WARP:MAX property. In practice, this would mostly be used like the WARP:MODE option, but with physics mode indicated by a value of 3, and rails by a value of 7.
  4. Fix the KSP bug by convincing KSP to check if it should automatically switch to rails mode more often, as it should.

Any one of these changes would allow me to solve my current problem, but the most comprehensive solution on KOS' part would be to implement 1, 2, and 3 combined. I strongly suspect that 4 is possible to do in a plugin, but I understand that is outside of the scope of the KOS project.

erendrake commented 10 years ago

I decided to do #1 and #2. I had no idea how long this one had been open :P 3 might still be useful but i think it would be part of a much finer time control api like the "Time Control" mod

thanks @tsbockman

SonnyJim commented 9 years ago

I'm still getting "Array index is out of range." when doing things like "SET WARP TO 0." :\

erendrake commented 9 years ago

when you say "things like" do you mean that there is a line of your code that reads

SET WARP TO 0.

and you get that exception?

SonnyJim commented 9 years ago

yes, but strangely I've not had this bug in a while. I think what was causing it was to go into physical time warp under 69500, then try changing warp > 70km