Page 1 of 1

Saving place on separate ged

PostPosted: Sun Jan 02, 2011 8:19 pm
by igamer
Ok let say i have a game that has 4 GEDs. Lets say I saved the game in the 3rd Ged file . But when I open the 1st Ged and press load , I want to open 3rd Ged or which ever Ged file I pressed save.

Re: Saving place on separate ged

PostPosted: Sun Jan 02, 2011 8:25 pm
by skydereign
Easiest way is to have a variable in the save file telling you which game it was. You could use strings, but since you have to compare values, I'd use an int.
Code: Select all
loadVars("vars", "vars");
switch(gameNumber)
{
    case 0:
    LoadGame("game0.ged");
    break;

    case 1: // current game
    // do nothing
    break;

    case 2:
    LoadGame("game2.ged");
    break;
}


Of course that goes into the view's create. When you save, you set gameNumber equal to the game's equivalent index.

Re: Saving place on separate ged

PostPosted: Tue Jan 25, 2011 7:59 am
by hamdotkeren
how when I have a game that cotains of an exe (menu) and 4 dat (4 stages) files. and I want to save my highscore at every stage. after completion I want to open the menu and see a list at each stage the number highscore in menu. can it??

Re: Saving place on separate ged

PostPosted: Tue Jan 25, 2011 8:04 am
by skydereign
It can. You would need either savefiles for each dat, or create an array of variables holding the hiscore for each game. The array is neater, as there is only one save file, so here's how it works.

You'll be loading the variables at the beginning of each game (the exe and dat files). Each level should know which hiscore it should save into, by way of an index, or you simply telling it [0], [1], etc. Simply save the hiscore when you exit the .dat file, and you have all of the hiscores for each .dat file in your save file.

In your menu exe, it should also load the save file, and you have all the hiscores there, in the array.

Re: Saving place on separate ged

PostPosted: Tue Jan 25, 2011 8:56 am
by hamdotkeren
thanks sky, I'll try it

Re: Saving place on separate ged

PostPosted: Fri Feb 04, 2011 2:16 pm
by hamdotkeren
hi sky...
1. I have a little problem, I have a save file that contains the variable with the array 10. then on my game highscore list I made one actor to perform load, then by using 9 clone from these actors and use the "switch" function I want to do a load as well as for an array of different, but the result does not work,
this is my code
Code: Select all
switch(cloneindex)
{
case 0:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[0];
break;
case 1:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[1];
break;
case 2:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[2];
break;
case 3: loadVars("score.txt", "sorokan"); stage.textNumber=kotak[3];
break;
case 4:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[4];
break;
case 5:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[5];
break;
case 6:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[6];
break;
case 7:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[7];
break;
case 8:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[8];
break;
case 9:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[9];
break;
}

kotak is array variable
stage is an actor

2. I want to make the highscore list like other games that contained the sequence name from the highest scoring player to score the lowest, number around 40 people. Can you give me directions?

Re: Saving place on separate ged

PostPosted: Fri Feb 04, 2011 8:20 pm
by schnellboot
1. I don't see any mistakes in your code
Did you set up the stage actor correctly with font and number as text?

Re: Saving place on separate ged

PostPosted: Sun Feb 06, 2011 1:49 pm
by hamdotkeren
this is my file, if I use 10 actors, then the load function can work but why when using an actor and 9 clone, then the load function does not work,

please help

Re: Saving place on separate ged

PostPosted: Sun Feb 06, 2011 7:33 pm
by schnellboot
Delete everything in Draw Actor of "stage" and write this
Code: Select all
Actor *get;
char str[32];
sprintf(str,"stage.%i",cloneindex);
get=getclone(str); get->textNumber=kotak[cloneindex];

code by Bee-Ant

And you can delete every loadVars function in you code and write in once in Create Actor of view actor.

Re: Saving place on separate ged

PostPosted: Sun Feb 06, 2011 11:46 pm
by hamdotkeren
thank you very much,
the code has worked, can you explain how this code work?

and can you give directions to my question number 2?

Re: Saving place on separate ged

PostPosted: Sun Feb 06, 2011 11:53 pm
by schnellboot
1. Sorry ask Bee how it works xD
2. I'm sorry I don't know

Re: Saving place on separate ged

PostPosted: Sun Feb 06, 2011 11:59 pm
by skydereign
Code: Select all
Actor *get;
// An Actor* is essentially a way of accessing an actor (Actor pointer)

char str[32];
// make a char array to hold the clonename (used by getclone)

sprintf(str,"stage.%i",cloneindex);
// set the char array equal to the clonename of the corresponding stage actor
// so, str = stage.cloneindex

get=getclone(str);
// set the Actor * get to the actor stage.cloneindex

get->textNumber=kotak[cloneindex];
// this is how you use an Actor *
// get->textNumber gives you the actor's textNumber


Concerning your other question, have you looked at Bee-Ant's Sort function? That should work for your hiscore mechanism.

Re: Saving place on separate ged

PostPosted: Mon Feb 07, 2011 1:25 am
by hamdotkeren
2 schnellboot: ok, never mind, thank's 4 your help

2 sky: thank you,