Page 1 of 1

A save game glitch

PostPosted: Sun Jul 15, 2012 6:24 pm
by lverona
Hey!

I am doing a game that saves player's progress. Everything worked fine and suddenly GE began to glitch - or so I believe.

In the game the player collects orbs. Each time he collects an orb, orb cloneindex is written into an array which (through GE's GUI) is added to the save group. However, from a certain period of time what happened was that the save stopped working as it should - it would remember all orbs BUT the first one, or will remember all orbs BUT the last one. I am spending hours here looking through the code and trying to figure out what might be wrong, maybe some array handling, but so far I could find nothing! The code is very transparent and I did not change anything in the code since the time it was working.

Maybe someone experienced something similar or at least you can advice where to look. Or maybe it is a GE glitch? I will supply more info if needed.

Re: A save game glitch

PostPosted: Sun Jul 15, 2012 6:37 pm
by lverona
Here is how I load orb states from a save file. This is Script Editor when an orb clones are created. SaveGame[8] is a number of collected orbs and an array orbs[i] is an array which keeps cloneindexes of collected orbs. Both are loaded from a save file. Both appear to be normal when I print out the values in them. However, for some reason the values in OrbSpots turn out 0 - either for first orb or for last. And this is erratic - sometimes like this, sometimes like that.

Code: Select all

short int i;

//removing orbs already taken by player

if(SaveGame[8]>0){

   for(i=0;i<SaveGame[8];i++){
 
        if(cloneindex==orbs[i]){
        DestroyActor("Event Actor");
        CreateActor("ring", "ring1", "(none)", "(none)", x, y, true);
        OrbSpots[0][i]=x;
        OrbSpots[1][i]=y;
        }
 
                         }

}


Re: A save game glitch

PostPosted: Sun Jul 15, 2012 7:10 pm
by lverona
Guess what, I am now running tests and I just found out that orb.4 does not get saved. It is just a normal clone, just like all others. There are 15 orbs in the game and thus 15 clones, from 0 to 14. And for some reason orb.4 does not save %) How can that be? orbs[i] does give out cloneindex 4. But OrbSpots just does not receive x and y. In fact, cloneindex==orbs[i] just does not happen. Could it be that there is a glitch in a clone that it reports its cloneindex incorrectly somehow on game start?

Re: A save game glitch

PostPosted: Sun Jul 15, 2012 11:04 pm
by skydereign
How are you creating the clones? One thing that you can't rely on is the order in which the clones appear in if you created them on the stage (because when you export the game, it won't necessarily create them in the same order). Can you post your game? Or at least all the save/load code you are using?

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 5:39 am
by lverona
I don't rely on the order of clone creation at all, the code above just checks for the cloneindex and acts according to it.

I will post a game here for you to look at. I will experiment though by perhaps recreating the clones in GE GUI and making sure it is not code but perhaps a GE oddity.

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 5:57 am
by lverona

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 5:59 am
by lverona
This is a test game, I took all the orbs and placed them in the start. Each time you collect an orb, it saves automatically, you can also save by pressing S. Collect most of them, then restart game - you'll see that one of the orbs is uncollected.
Go to scripts, orb->Create Actor. This is where save code works - when you create a clone, you see if cloneindex exists in orbs array, which is gotten from a save file, and if it does - you destroy the orb and put a ring in its place (to show that it has been collected). For some reason this happens to all but clone number 4.

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 9:46 am
by lverona
Tested today - now clone.4 is saved, clone.0 is not. This is weird.

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 10:12 am
by skydereign
Ah, a similar problem to the one I mentioned. In a way your code does rely on the order of creation (just not for the clones). The problem is that the player isn't necessarily created first (so the load doesn't happen yet). The only create event you can be sure of happening first is the view's create actor event. Just load it from there and it should work.

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 11:50 am
by lverona
Actually, I did try this out yesterday, it did not help. I can retry again.

Re: A save game glitch

PostPosted: Mon Jul 16, 2012 11:54 am
by lverona
Retried. It does work now! Maybe I did something else wrong yesterday... Thank you, hope this was really the only problem!