Blockland Forums > Modification Help
Script crashes game
Placid:
--- Code: ---$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);
}
}
}
}
}
}
--- End code ---
Whenever I attempt to run this script, it always crashes. When I check the console.log, I find this:
--- Code: ---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
--- End code ---
...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.
otto-san:
%file = openForRead
What.
Placid:
oh holy forget what
Amade:
Just change
--- Code: ---%file = openForRead("config/client/Dungeons/dungeon1.txt");
--- End code ---
to
--- Code: ---%file.openForRead("config/client/Dungeons/dungeon1.txt");
--- End code ---
Placid:
Alright, I fixed that, and yes, I knew, Amade.
I also fixed the fact that placeBrick isn't a function. I added echos to see where it comes out and all that.
It still crashes, however, it's running through the full script and should be placing the bricks, but it's not. Anyone got any suggestions?
It ran through every brick's loop.