Blockland Forums > Modification Help

Script crashes game

Pages: << < (2/4) > >>

otto-san:

serverCmdPlaceBrick isn't it? Something like that?
commandToServer('placeBrick');

Greek2me:

Use commandToServer('plantBrick');

Also, can you post your console log along with an updated script showing where your echoes are?

Destiny/Zack0Wack0:

Change this:

--- Code: ---for(%i="-1";%i<%dungeon_length;%i++)

--- End code ---
to this:

--- Code: ---for(%i=0;%i<%dungeon_length;%i++)

--- End code ---

Change the schedules so they're not all at the same time:

--- Code: ---%time += 500;
schedule(%time,...)

--- End code ---


Placid:

Here's the code:

--- 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_bcount="0";
%dungeon_length=getwordcount(%line);
for(%i="-1";%i<%dungeon_length;%i++) {
%tempchar=getword(%line,%i);
if(%tempchar $="x") {
plantBrick(1);
schedule(500,0,commandtoserver,supershiftbrick,0,0,1);
plantbrick(0);
schedule(500,0,commandtoserver,supershiftbrick,1,0,1);
%dungeon_bcount++;
echo("Placing brick: " @ %dungeon_bcount @ ".");
}
if(%tempchar $="o") {
schedule(500,0,commandtoserver,supershiftbrick,1,0,0);
%dungeon_bcount++;
echo("Omitting brick: " @ %dungeon_bcount @ ".");
}
if(%dungeon_bcount $= %dungeon_length) {
schedule(500,0,commandtoserver,supershiftbrick,-1*%dungeon_length,-1,0);
}
}
}
}
}
--- End code ---
note that the whole brackets thing might be a bit messy, but it does execute.

...and here's the console part where it starts to echo:

--- Code: ---==>dungeon_make();
Placing brick: 1.
Placing brick: 2.
Placing brick: 3.
Placing brick: 4.
Placing brick: 5.
Placing brick: 6.
Placing brick: 7.
Placing brick: 8.
Placing brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Omitting brick: 3.
Placing brick: 4.
Omitting brick: 5.
Omitting brick: 6.
Placing brick: 7.
Omitting brick: 8.
Omitting brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Placing brick: 3.
Omitting brick: 4.
Placing brick: 5.
Omitting brick: 6.
Omitting brick: 7.
Placing brick: 8.
Omitting brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Omitting brick: 3.
Omitting brick: 4.
Omitting brick: 5.
Placing brick: 6.
Omitting brick: 7.
Omitting brick: 8.
Omitting brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Omitting brick: 3.
Placing brick: 4.
Omitting brick: 5.
Placing brick: 6.
Placing brick: 7.
Omitting brick: 8.
Placing brick: 9.
Placing brick: 10.
Placing brick: 1.
Placing brick: 2.
Omitting brick: 3.
Omitting brick: 4.
Omitting brick: 5.
Placing brick: 6.
Placing brick: 7.
Omitting brick: 8.
Placing brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Omitting brick: 3.
Placing brick: 4.
Omitting brick: 5.
Placing brick: 6.
Omitting brick: 7.
Omitting brick: 8.
Omitting brick: 9.
Placing brick: 10.
Placing brick: 1.
Omitting brick: 2.
Omitting brick: 3.
Omitting brick: 4.
Omitting brick: 5.
Omitting brick: 6.
Omitting brick: 7.
Omitting brick: 8.
Omitting brick: 9.
Placing brick: 10.
Placing brick: 1.
Placing brick: 2.
Placing brick: 3.
Omitting brick: 4.
Omitting brick: 5.
Placing brick: 6.
Omitting brick: 7.
Placing brick: 8.
Placing brick: 9.
Placing brick: 10.
Placing brick: 1.
Placing brick: 2.
Placing brick: 3.
Placing brick: 4.
Placing brick: 5.
Placing brick: 6.
Placing brick: 7.
Placing brick: 8.
Placing brick: 9.
--- End code ---

It runs through each row and assigns each brick a number. I believe it crashes as it places the last brick, but I'm not quite sure.


--- Quote from: Destiny/Zack0Wack0 on May 25, 2011, 02:36:15 AM ---1. Change this:

--- Code: ---for(%i="-1";%i<%dungeon_length;%i++)

--- End code ---
to this:

--- Code: ---for(%i=0;%i<%dungeon_length;%i++)

--- End code ---

2. Change the schedules so they're not all at the same time:

--- Code: ---%time += 500;
schedule(%time,...)

--- End code ---

--- End quote ---
1. I wanted it to start at zero and go up, as it's getting a word from a line. Wouldn't I need to start at "-1" because as you state it the variable gets incremented, or am I understanding the order of things wrong?
2. What would this change? I thought I had the delays in the function, and it's not that I don't believe you, I'd like an explanation about what it would do for the function.

Destiny/Zack0Wack0:

1. The %i= part of the for statement is what the value starts as, the end part is what it does AFTER the stuff inside the for loop has been processed.
2. At the moment you're scheduling for 500 milliseconds, and because it's just looping straight through them it's going to do every single shift of the brick in 500 milliseconds, rather than having a 500 millisecond gap. Either remove the schedules altogether or make it like that.
The reason it's crashing is probably because you're overflowing it with useless schedules that all happen at the same time.
Also, change placeBrick to commandToServer('plantBrick'); like suggested earlier.

Pages: << < (2/4) > >>

Go to full version