Saving Clones : Save and Load User-Created Clones
Posted: Fri May 16, 2008 10:45 pm
I have found a method for saving an array of user created clones.
First, you create three integer variables...For this post i'm using 'myx', 'myy', 'clonetotal'.
For myx and myy variable, assign the following properties; Array - yes. size - up to you. save (set savegroup); For clonetotal, assign save: (set savegroup);
Now create two actors, one called load and one called save;
On save>mousebuttondown, Create a short timer for the savebutton, and a shorter timer for the clones.
mousebuttondown:
clonetotal=ActorCount("clonename");
On the clone timer, do this:
myx[cloneindex]=x;
myy[cloneindex]=y;
and on the timer for the save button
saveVars("filename", "savegroup");
Now on the Load button > createactor
loadVars("filename", savegroup);
and on Load button > mousebutton down create two timers; short one for loadbutton, and longer one for clones;
Loadbutton > timer
if (clonetotal > 1){Createactor("clonename etc. etc.); clonetotal-=1;}
You'd probably want to use a LOOP here instead of if, but this is just a basic version. Figure out the loop thing on your own!
and on the clonetimer
x=myx[cloneindex];
y=myy[cloneindex];
That's It! Note that you can save ANY clone variable this way...health, poweruplevel...anything, just remember to create a new integer array for each value to be stored.
Here's a Demo to further explain:
First, you create three integer variables...For this post i'm using 'myx', 'myy', 'clonetotal'.
For myx and myy variable, assign the following properties; Array - yes. size - up to you. save (set savegroup); For clonetotal, assign save: (set savegroup);
Now create two actors, one called load and one called save;
On save>mousebuttondown, Create a short timer for the savebutton, and a shorter timer for the clones.
mousebuttondown:
clonetotal=ActorCount("clonename");
On the clone timer, do this:
myx[cloneindex]=x;
myy[cloneindex]=y;
and on the timer for the save button
saveVars("filename", "savegroup");
Now on the Load button > createactor
loadVars("filename", savegroup);
and on Load button > mousebutton down create two timers; short one for loadbutton, and longer one for clones;
Loadbutton > timer
if (clonetotal > 1){Createactor("clonename etc. etc.); clonetotal-=1;}
You'd probably want to use a LOOP here instead of if, but this is just a basic version. Figure out the loop thing on your own!
and on the clonetimer
x=myx[cloneindex];
y=myy[cloneindex];
That's It! Note that you can save ANY clone variable this way...health, poweruplevel...anything, just remember to create a new integer array for each value to be stored.
Here's a Demo to further explain: