Quote:
Originally Posted by callimuc
You have like a template level. You always load that one file as a text (using loadLines() or whatever you want to use) and have the script look for a certain warp you want to manipulate (lets say the format is 'LINK 30 30 some_level.nw' ; I'm not too sure didn't check it). After you've found that / them, you simply alter the Level name like:
PHP Code:
temp.newlevel = "new_level.nw";
temp.line = yourFoundLINKLocationInsideTheFile.tokenize();
// LINK x y levelname
temp.line = temp.line[0] SPC temp.line[1] SPC temp.line[2] SPC temp.newlevel
and save those edited lines via saveLines() as a new level. Make sure to keep your level template unedited - it's a template
TBH I've never really tried editing the links directly like that, but that's the way that I can think of right now. Probably would end up changing it all again
|
Like Callimuc said, here is a piece that might help from Instance System from Novo. A tad was changed by me below.
We actually find the links using a identifiable name such as original. All our instance levels are levelname-original.nw.
to get the copy_id, we calculate each instance created (Ex: this.copy_counter.(@temp.id) ++;//temp.id would be the instance type)
PHP Code:
temp.original_level = levelname-original.nw;
temp.lines.loadlines("levels/instance/"@ temp.original_level);
temp.newlines = new[0];
for (temp.line: temp.lines) {
temp.original_pos = temp.line.pos("original");
while (temp.original_pos != -1) {
temp.line = temp.line.substring(0, temp.original_pos) @ temp.copy_id @ temp.line.substring(temp.original_pos + strlen("original") - 2);
temp.original_pos = temp.line.pos("original");
}
temp.newlines.add(temp.line);
}
And what this does is it copys the x and y coordinates of your original level, and renames the copied level as well as the links.