Use serialize
In my bgt days serialize saved my life but... I just would never do something like this anymore when in more less primitive programming language you can save entire game objects to files, pickle, or JSON strings...
If you are just starting out why don't you learn to code with js or python? we can point you in the right direction.
I remember rhythm rage save files were a pain to save!
Want to see my rhythm rage save level function? that is a pain!
void set_level(string level,string value,string pack) {
int whichone=-1;
string info;
ok=unlockinfo.get(pack+".pack",info);
string[] lvl=string_split(info,",,,",true);
for (uint i=0;i<lvl.length();i++) {
if (string_left(lvl[i],level.length())==level) {
whichone=i;
break;
}
}
if (whichone!=-1) {
lvl.remove_at(whichone);
}
lvl.insert_last(level+"==="+value);
string built;
for (uint i=0;i<lvl.length();i++) {
built+=lvl[i]+",,,";
}
unlockinfo.set(pack+".pack",built);
ser();
}
//the save function looks like this
void ser() {
if (creatingpack) {
return;
}
//if (!SCRIPT_COMPILED) return;
dictionary data;
data.set("cash",cash);
data.set("unlocks",unlocks);
data.set("pack",pack);
//save unlocks here
string[] save=unlockinfo.get_keys();
string savea;
for (uint i=0;i<save.length();i++) {
ok=unlockinfo.get(save[i],savea);
if (!ok) {
if (lang==1)
alert("error","error saving unlocked level information.");
if (lang==2)
alert("error","Hubo un error al guardar tu información sobre paquetes desbloqueados. Puede que encuentres algún problema.");
break;
}
data.set("u."+save[i],savea);
for (uint u=0;u<savea.length();u++) {
}
}
data.set("achievements",achievements);
string srld=serialize(data);
string esrld=string_encrypt(srld,"soyelputoamo");
file fld;
fld.open(DIRECTORY_MY_DOCUMENTS+"\\rg.dat","wb");
fld.write(esrld);
fld.close();
}
//with the new version made in js I can just save an object like
function set_level(level,value) {
data.unlocks[pack]["levels"][level]=value;
save();
}
//And the save function is just this.
export function save() {
if (!fs.existsSync(os.homedir() + '/rpacks')) {
fs.mkdirSync(os.homedir() + '/rpacks');
}
let write = JSON.stringify(data);
//write=mangle.encrypt(write);
fs.writeFileSync(os.homedir() + '/rpacks/save.dat', write);
}
that's it.
Just trying to give you an example as to why you should use a more modern programming language.
If you don't see the difference...
ReferenceError: Signature is not defined.