ScriptUO
Scripting Resources & Utilities => Stealth Client => Topic started by: blackbeard on September 21, 2015, 01:02:10 AM
-
Hi,
How to solve this?
program walk;
procedure andar();
var
i, x, randomx, randomx2, y, randomy, randomy2 : integer;
tileinfo : tstaticcell;
begin
randomx := random(10);
randomx2 := random(10);
randomy := random(10);
randomy2 := random(10);
x := getx(self) + randomx - randomx2;
y := gety(self) + randomy - randomy2;
tileinfo := ReadStaticsXY(x, y, WorldNum);
if tileinfo.staticcount > 0 then
for i := Low(TileInfo.Statics)to high(TileInfo.Statics) do
begin
if (TileInfo.Statics[i].Tile >= 1339) and (TileInfo.Statics[i].Tile <= 1359) and (TileInfo.Statics[i].z = GetZ(self)) then
begin
newmovexy(x,y,true,0,false);
end
else
begin
addtosystemjournal('did not find cave floor');
andar();
end
end;
end;
begin
andar();
end.
i have this pascal problem, the program aren't making the loop when he is not on a cave, the script stops.. why?
-
program walk;
procedure andar();
var
i, x, randomx, randomx2, y, randomy, randomy2 : integer;
tileinfo : tstaticcell;
begin
randomx := random(10);
randomx2 := random(10);
randomy := random(10);
randomy2 := random(10);
x := getx(self) + randomx - randomx2; //so Range can be +10 to -10
y := gety(self) + randomy - randomy2; //So Range can be +10 to -10
tileinfo := ReadStaticsXY(x, y, WorldNum);
if tileinfo.staticcount > 0 then
begin // Missing begin
for i := Low(TileInfo.Statics)to high(TileInfo.Statics) do // if you use an Array then you could do 0 to Count - 1
begin
if (TileInfo.Statics[i].Tile >= 1339) and (TileInfo.Statics[i].Tile <= 1359) and (TileInfo.Statics[i].z = GetZ(self)) then
begin
newmovexy(x,y,true,0,false);
end
else
begin
addtosystemjournal('did not find cave floor');
andar(); // You call yourself recursive? this will do trouble because if you arent in a cave this will overflow!!
end
end;
end; // And then missing an end
end;
begin
andar();
end.
Check my comments..
-
thx, I know. But he only uses this procedure when he is inside a cave, so there will not be any overflow, he simple doesn't get out of the cave.
actualy i solved this problem.