Jump to content

Adding levels of time warp


Superfluous J

Recommended Posts

I should really title this "Not adding levels of time warp" because I can't figure out how to do it :)

I've got this little bit of code:

            TimeWarp timeWarp = (TimeWarp)FindObjectOfType(typeof(TimeWarp));
            print("WarpConfigurator.warprates before: (" + timeWarp.warpRates.Length + ") ");
            for (int i = 0; i < timeWarp.warpRates.Length; i++)
            {
                print(i + ": " + timeWarp.warpRates[i]);
            }
            Array.Resize(ref timeWarp.warpRates, timeWarp.warpRates.Length + 2);
            timeWarp.warpRates[timeWarp.warpRates.Length-2] = timeWarp.warpRates[timeWarp.warpRates.Length-3] * 10;
            timeWarp.warpRates[timeWarp.warpRates.Length-1] = timeWarp.warpRates[timeWarp.warpRates.Length-2] * 10;
            print("WarpConfigurator.warprates after: (" + timeWarp.warpRates.Length + ") ");
            for (int i = 0; i < timeWarp.warpRates.Length; i++)
            {
                print(i + ": " + timeWarp.warpRates[i]);
            }

And here's what ends up in my log (with unimportant stuff trimmed)

WarpConfigurator.warprates before: (8) 
0: 1
1: 5
2: 10
3: 50
4: 100
5: 1000
6: 10000
7: 100000
WarpConfigurator.warprates after: (10) 
0: 1
1: 5
2: 10
3: 50
4: 100
5: 1000
6: 10000
7: 100000
8: 1000000
9: 1E+07

So, I know the numbers are there. However, in the game when I use > to speed up time, when I get to level 7 it stops just like always.

Is there something else I need to set? Some variable that specifies the maximum warp level? I can't find one, and don't even know where to look.

Link to comment
Share on other sites

17 minutes ago, Streetwind said:

Maybe it'll help you to look at the source of BetterTimeWarp here: https://github.com/HappyFaceIndustries/BetterTimeWarp

Unfortunately the author hasn't had time to work on it for quite a while, so it's still stuck on KSP 1.0.5... but hey, who knows.

I actually did look at that, and WarpUnlocker. Neither change the number of steps, from what I can tell.

Link to comment
Share on other sites

In case anybody else ever stumbles on this, I found out the problem. That above code was fine, the problem was I did not resize each world's timeWarpAltitudeLimits array. The ">" keypress won't go further than that array's size.

Here's the code that worked with the above code:

            foreach (CelestialBody iCelestialBody in FlightGlobals.Bodies)
            {
                Array.Resize(ref iCelestialBody.timeWarpAltitudeLimits, timeWarp.warpRates.Length);
/*                for (int i = 0; i < iCelestialBody.timeWarpAltitudeLimits.Length; i++)
                {
                    iCelestialBody.timeWarpAltitudeLimits[i] = 0;
                } */
            }

The part I commented out, if you remove the commenting, will unlock time warp no matter how close you are to a world's surface or atmosphere. Expect to see the whole shebang soon in a little mod for 1.2.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...