Load information via-level?

Non-platform specific questions.

Load information via-level?

Postby Hblade » Sun May 16, 2010 1:29 pm

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.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Load information via-level?

Postby Camper1995 » Sun May 16, 2010 3:52 pm

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
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Load information via-level?

Postby DST » Sun May 16, 2010 4:37 pm

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Load information via-level?

Postby Hblade » Sun May 16, 2010 4:40 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Load information via-level?

Postby Camper1995 » Sun May 16, 2010 4:41 pm

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
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Load information via-level?

Postby Hblade » Sun May 16, 2010 5:10 pm

After you saved and loaded the vars, it will automatically = 1 :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Load information via-level?

Postby Camper1995 » Sun May 16, 2010 5:34 pm

Oh, :oops: OK. :D

Thank you.
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Load information via-level?

Postby Hblade » Sun May 16, 2010 5:52 pm

Your welcome ;3



And thanks, D :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest