Author Topic: Help with tile name  (Read 4070 times)

0 Members and 1 Guest are viewing this topic.

Offline blackbeardTopic starter

  • Restricted
  • **
  • Posts: 10
  • Activity:
    0%
  • Reputation Power: 1
  • blackbeard has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Help with tile name
« on: September 21, 2015, 01:02:10 AM »
0
Hi,


How to solve this?


Code: [Select]

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?
« Last Edit: September 21, 2015, 03:18:06 AM by blackbeard »

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Help with tile name
« Reply #1 on: September 21, 2015, 04:15:11 AM »
0
Code: [Select]

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..

Offline blackbeardTopic starter

  • Restricted
  • **
  • Posts: 10
  • Activity:
    0%
  • Reputation Power: 1
  • blackbeard has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Help with tile name
« Reply #2 on: September 21, 2015, 11:07:27 AM »
0
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.


Tags: Tile name