So, I'm trying to do a check on every level uploaded to the server. However, It's coming out with some weird things when I am wanting to write the lines back. Here's the script, basically what it is doing is running through each line in the level uploaded and checking if it's got anything illegal in it, if it does it deletes that entire NPC [from 'NPC image x y' to 'NPCEND'], here's what I have so far...
HTML Code:
function onLevelFileUpdated(file){
temp.lines.loadlines("levels/" @ temp.file);
temp.newlines.loadlines("levels/" @ temp.file);
temp.illegal = {"item", "client", "rupee", "player"};
for (temp.i: temp.lines) {
temp.currentline++;
if (i.starts("BOARD")) continue;
if (i.starts("GLEV")) continue;
if (i.starts("LINK")) continue;
if (i == "NPCEND") {
if (temp.bad == true) {
temp.total = temp.currentline - temp.count;
for (temp.t = temp.count; temp.t < (temp.count + temp.total); temp.t++)
temp.newlines.delete(t);
temp.currentline = count - 1;
temp.bad = false;
continue;
}
}
if (i.starts("NPC")) temp.count = temp.currentline;
for (temp.scan: temp.illegal) {
if (i.lower().pos(scan) != -1) temp.bad = true;
}
}
temp.newlines.savelines("levels/" @ temp.file, 0);
}