So- I saw Ziro's post regarding his text replace, I made one similar to this when working on Era Dev, this one just replaces the classes mentioned though-
HTML Code:
function onCreated() {
temp.folder.loadfolder("levels/world/overworld/*.nw", 0);
echo("Scanner: Started at" SPC timevar2);
this.onScan(temp.folder);
}
function onScan(folder) {
for (temp.s = 0; temp.s < 50; temp.s++) {
if (temp.s > temp.folder.size()) break;
temp.level = temp.folder[temp.s];
temp.data.loadlines("levels/world/overworld/" @ temp.level);
temp.count = 0;
for (temp.l: temp.data) {
temp.t = temp.l.tokenize();
if (temp.l.pos("tree") >= 0)
temp.data[temp.count] = "this.join(\"env-tree\");";
if (!temp.l.starts("NPC")) {
if (temp.l.pos("shrub") >= 0)
temp.data[temp.count] = "this.join(\"env-tree_shrub\");";
elseif (temp.l.pos("parkbench") >= 0)
temp.data[temp.count] = "this.join(\"env-parkbench\");";
elseif (temp.l.pos("smoke") >= 0)
temp.data[temp.count] = "this.join(\"particle-graysmoke\");";
elseif (temp.l.pos("wire-fence") >= 0)
temp.data[temp.count] = "this.join(\"env-fence_wire\");";
elseif (temp.l.pos("barrel") >= 0)
temp.data[temp.count] = "this.join(\"env-barrel\");";
elseif (temp.l.pos("hydrant") >= 0)
temp.data[temp.count] = "this.join(\"env-hydrant\");";
elseif (temp.l.pos("mailbox") >= 0)
temp.data[temp.count] = "this.join(\"env-mail_box\");";
elseif (temp.l.pos("box") >= 0)
temp.data[temp.count] = "this.join(\"env-box\");";
}
temp.count++;
}
temp.data.savelines("levels/" @ temp.level, 0);
echo("Scan: Replaced" SPC temp.level @ "!");
temp.folder.delete(temp.s);
}
if (temp.folder.size() > 0)
scheduleevent(1, "Scan", {temp.folder});
else
echo("Scanner: Finished at" SPC timevar2);
}