Results 1 to 7 of 7

Thread: Out of Range GRRRR

  1. #1
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Out of Range GRRRR

    The Function
    SCAR Code:
    Function WalkPath(Dir: String): boolean;
    var
      Path, OnMap: TPointArray;
      BankTile: TTile;
      ThePoint: TPoint;
      i: integer;
    begin
      SetLength(Path, 40);
      SetLength(OnMap, 1);
      Path := LoadPath;
      BankTile := Tile(3093, 3490);
      repeat
        if(not(R_LoggedIn))then
          if(not(LoggedInBB))then
          begin
            Players[CurrentPlayer].Active := False;
            LogOut;
          end;
        if(TileOnMM(BankTile))then
        begin
          ThePoint := TileToMM(BankTile);
          Mouse(ThePoint.x, ThePoint.y, 3, 3, true);
          Wait(100 + random(50));
          R_Flag;
          Result := True;
          Exit;
        end;
        for i := 0 to 40 do
        begin
          ThePoint := TileToMM(Tile(Path[i].x, Path[i].y));
          if(PointInBox(ThePoint, IntToBox(mmx1, mmy1, mmcx, mmy2)))then
          begin
            OnMap[High(OnMap)] := ThePoint;
            SetLength(OnMap, High(OnMap) + 2);
          end;
        end;
        if(Length(OnMap) = 0)then
        begin
          Result := False;
          Exit;
        end;
        if(Dir = 'N')then
          SortTPAFrom(OnMap, IntToPoint(mmcx, mmy1))
        else
          SortTPAFrom(OnMap, IntToPoint(mmcx, mmy2));
        ThePoint := OnMap[0];
        if(ThePoint.x > 0) and (ThePoint.y > 0)then
        begin
          Mouse(ThePoint.x, ThePoint.y, 3, 3, true);
          Wait(100 + random(50));
          R_FFlag(10);
        end else
        begin
          Result := False;
          Exit;
        end;
      until(false)
    end;

    The error is this line

    SCAR Code:
    ThePoint := TileToMM(Tile(Path[i].x, Path[i].y));

    And I'm using Simba.

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    for i := 0 to 39 do//needs to be one less than the length. the actual length of the array is outside the largest slot number.
    begin
    ThePoint := TileToMM(Tile(Path[i].x, Path[i].y));
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The length is correct at 40 for the array.

  4. #4
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    no length 40 goes for 0..39

    you go

    SCAR Code:
    from i := 0 to 40 do

    it should be

    SCAR Code:
    from i := 0 to 39 do

    or alternatively

    SCAR Code:
    for i := 0 to high(Path) do
    “Ignorance, the root and the stem of every evil.”

  5. #5
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks a lot.

  6. #6
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by bbri06 View Post
    Thanks a lot.
    Thats what I told you.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  7. #7
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know, that's why I repped you, Noidea. I just was somehow thinking I had it right -.-

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •