Page 1 of 1

Load information via-level?

PostPosted: Sun May 16, 2010 1:29 pm
by Hblade
Okay guys, I need some help here :3 Whats the easiest way I can get my "database" editor to load information based on variables that were randomly created by the user to read from up to 0 to 100, for example I have a function:

Stats: Random

Where random is clickable, Also of course, all levels will have editable stats, such as Attack, Def, HP, Mag, and all that goodie goodie stuff but uh O.o how?

I know of one method but it's complicated and it'll take ages lol, which I dont mind doing if there is no other way of doing this.

Re: Load information via-level?

PostPosted: Sun May 16, 2010 3:52 pm
by Camper1995
Hm..I must sorry to you, but I can't help you. But I have similar problem.
Something like, how to make achievements? You know, how to save variable?

(I dont want to make new theard for this :P )

Example: I have 0/1 golden eggs.
> I collect one egg > variable "bonus" = 1;
> saveVars > and what? how to save that variable bonus is turned on 1?

So, when I start my game, automatickly loadVars and bonus=1; so I can have some real bonuses because
I collected that goled egg.

Can you help me?

Thank you,

CAmPeR :D

Re: Load information via-level?

PostPosted: Sun May 16, 2010 4:37 pm
by DST
Camper: Use the 'save group' option in the variables tab.

Hblade: If you have a lot of variables to save, you should dump everything to an array. To use the savegroup option, it must be a 1dimensional array. You can sort the array with a variable. (i'll use global int lastsaved). Write a custom function for it, like so:

//this example assumes up to 10 variables per unit

Code: Select all
void saveActor(){ //you don't have to enter anything if this function is called within the specified actor's script.
int i=lastsaved*10;
savearray[i]=hp;
savearray[i+1]=def;
savearray[i+2]=att;

lastsaved++;
}


then just load it the same way, reading in groups of 10, and incrementing lastsaved every time an actor finishes.

If you are using cloneindex as an id, and it is needed to be actor specific, then use cloneindex instead of lastsaved. However, if there are any holes in your cloneindex list, it will waste space in the array.

Re: Load information via-level?

PostPosted: Sun May 16, 2010 4:40 pm
by Hblade
Make the variable that stores the golden eggs have a save group called "saves" or something, to do this you must not create the variable with code, you have to create it in the variable list. Then, use this code:
Code: Select all
saveVars("Filename.gsf", "saves");


where Filename.gsf can be replaced with anything, such as "lolzaburger.aru" if ya wanted.

To load them from a different exe, go to that ged file, and then make the same variable with the same saved group name. Then, use
Code: Select all
loadVars("Filename.gsf", "saves");


Boom there ya have it :D You officially saved and loaded your variables

Re: Load information via-level?

PostPosted: Sun May 16, 2010 4:41 pm
by Camper1995
Sure DST, I am trying to use it. So:

when I pick up that "egg", bonus=1;

then: saveVars("data.dat","bonus");

and when the game start:

load vars(blah blah blah);
and what then?
bonus=1; ??

pls, if you understand what I am talking about, help me. xD

Thx,

CAmPeR :D

Re: Load information via-level?

PostPosted: Sun May 16, 2010 5:10 pm
by Hblade
After you saved and loaded the vars, it will automatically = 1 :D

Re: Load information via-level?

PostPosted: Sun May 16, 2010 5:34 pm
by Camper1995
Oh, :oops: OK. :D

Thank you.

Re: Load information via-level?

PostPosted: Sun May 16, 2010 5:52 pm
by Hblade
Your welcome ;3



And thanks, D :D