Description:
Copys levels from one folder in to another folder, without the scripts! It's magic
How-to:
this.structure = "levels/levels/overworld/";
The current folder that the levels are in
this.newfolder = "levels/newLevels";
The new folder that the levels will be placed in
Code: [Place as a Database NPC]
PHP Code:
function onCreated() {
this.structure = "levels/levels/overworld/";
temp.folder.loadfolder(this.structure @ "*", 0);
this.newfolder = "levels/newLevels";
this.onScan(temp.folder);
}
function onScan(folder) {
for (temp.g = 0; temp.g < 999; temp.g++) {
if (temp.g > temp.folder.size()) {
break;
}
temp.data.loadlines(this.structure @ temp.folder[temp.g]);
temp.newfile = new[temp.data.size()];
temp.c = 0;
for (temp.i: temp.data) {
if (temp.i.starts("LIN") || temp.i.starts("BOAR") || temp.i.starts("GLEVN")) {
temp.newfile[temp.c] = temp.i;
temp.c++;
}
}
for (temp.i = temp.c; temp.i < temp.newfile.size(); temp.i++) {
temp.newfile[temp.i] = null;
}
temp.newfile.savelines(this.newfolder @ temp.folder[temp.g], 0);
echo("Saved:" SPC temp.folder[temp.g]);
temp.folder.delete(temp.g);
}
if (temp.folder.size() > 0) {
scheduleevent(1, "Scan", {temp.folder});
} else {
echo("Finished copying levels!");
}
}
Oh, and don't forget to give the NPC server rights to each folder!