$dungeon_chars = "x o";
function dungeon_make(%dir) {
%file = new fileObject();
%file = openForRead("config/client/Dungeons/dungeon1.txt");
while(!%file.isEOF()) {
%line=%file.readline();
if(strLen(%line) > 2) {
%dungeon_length=getwordcount(%line);
for(%i="-1";%i<%dungeon_length;%i++) {
%tempchar=getword(%line,%i);
if(%tempchar !$= getword($dungeon_chars,0) || %tempchar !$= getword($dungeon_chars,1)) {
error("Dungeon Builder: Unrecognized character. Unable to continue.");
return;
}
else {
if(%tempchar $="x") {
placeBrick(1);
schedule(500,0,commandtoserver,supershiftbrick,0,0,1);
placebrick(0);
schedule(500,0,commandtoserver,supershiftbrick,1,0,1);
}
if(%tempchar $="o") {
schedule(500,0,commandtoserver,supershiftbrick,1,0,0);
}
if(%tempchar $="") {
schedule(500,0,commandtoserver,supershiftbrick,-1*%dungeon_length,-1,0);
}
}
}
}
}
}
Whenever I attempt to run this script, it always crashes. When I check the console.log, I find this:
add-ons/script_dungeongen/client.cs (7): Unable to find object: '' attempting to call function 'readLine'
BackTrace: ->ConsoleEntry::eval->dungeon_make
add-ons/script_dungeongen/client.cs (0): Unable to find object: '' attempting to call function 'isEOF'
BackTrace: ->ConsoleEntry::eval->dungeon_make...repeated so many times it crashes.
Does anyone see my error here? I used to have it go to %dir (a directory), but I changed it to see if it would fix the crash.
Also, I know that I forgot to %file.close(); and %file.delete(); but I don't think that would be causing the problem, as it's being bad on the reading of the file.
Look at my fourth reply.