0 votes
by (140 points)
I didn't know the first thing about coding when i started making my game. Now we're a few years later and i've cobbled together a game that works just fine. The problem is that it has become very, very slow as it grew (over half a million characters and A LOT of variables and if statements). It can take up to 7 seconds to go from one page to the next. Is there any way i can speed that up, without having to improve on the code itself. Its not that i don't want to do that, but i simply can't. I don't have the skills to do so.

I'm using sugarcube and (as far as i know) the latest version.

1 Answer

0 votes
by (68.6k points)

What version of SugarCube are you actually using (in full)?  It could be important.

Regardless.  There's absolutely no reason for seven second delays between passages in SugarCube v2 even if your game was many, many times larger as the only thing that matters in this case is the code you're actually executing upon transition.  I have a hard time believing that you're doing anything that would account for delays like that save for code that's doing some terribly inefficient things.

Without knowing more about your project, it's hard to say what you could do to address the problem.  It might be a simple fix or it could be very, very involved.

TL;DR: There is no magic bullet, bad code must be made better.  The changes you need might be trivial or they might be complicated.  We'd need to know more to be able to say.

by (68.6k points)

There was really no need to create another question simply to ask me (or anyone) to take a look at your code.  A comment here would have been the proper thing to do.


Can i send you my code so you can take a look at it?

Sure.  Do you have a link?

by (140 points)
by (68.6k points)

The former, the latter cannot be accessed by anyone but you.

Well, your code is barely holding together syntactically, let alone functionally.  You already knew it had issues though, so let's move on.


The simplest and quickest thing I can see would be to replace the following configuration setting in your Story JavaScript:

config.history.controls = false;

With the following:

Config.history.maxStates = 1;

The former only hides the history controls—it's also SugarCube v1 code, the equivalent v2 API being Config.history.controls.  The latter reduces the size of the history to a single state and hides the history controls, though it's the first bit that will help some here.

SEE: Config.history.maxStates


Anyway.  Try that out and see what it does for you.