Results 1 to 3 of 3

Thread: Find bank chest error

  1. #1
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default Find bank chest error

    Hello,

    I've recently been using the below newBankColorSetup procedure to find a bank chest. The overall script works fine when it locates 1 "potential bank", however there is an error when 2 "potential banks" are found. The error is as follows -> Error: Index out of range (index:1, low:0, high:0) at line 134. Execution failed.

    Line 134 is p := ATPA[i].MidPnt;
    I noticed in another script there was a similar issue when using ATPA[i].MidPnt as well, so I wonder if this has to do with the recent updates. I have just returned from a 4 month break so please bear with me. Any suggestions would be appreciated!


    Code:
    procedure newBankColorSetup();
    var
    i, Angle : integer;
    ourtestbank : TMSObject;
    Pnts      : TPointArray;
    ATPA: T2DPointArray;
    p : TPoint;
    begin
      with OurtestBank do
      begin
      ourtestbank.create('Chest', ['Chest','Bank chest'], [createCol(928570, 11, 0.07, 1.86)], [createCol(2566703, 7, 0.90, 0.87)], 150, 50, 70, 50);
      if ourtestbank.findall(10, MSCP, Pnts) then
        writeln('Found a possible '+toStr(length(Pnts))+ 'chests')
        //Ourtestbank.find(Pnts)
      else
      begin
        writeln('Failed to find the chest!');
        Angle := round(getcompassangle);
        setcompass(angle-randomrange(18,28));
        Exit;
        end;
      for i := 0 to High(Pnts) do
        begin
          ATPA := FloodFillTPA(pnts);
          p := ATPA[i].MidPnt;
          custommouse(p);
        end;
      end;
    end;

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Hi Hellzonee,

    Skimming through your code the first thing I noticed was this part:
    Simba Code:
    for i := 0 to High(Pnts) do
        begin
          ATPA := FloodFillTPA(pnts);
    Basically your creating a 2DPointArray for every single Pnts[..]. Try calling FloodFillTPA before instead, like so:
    Simba Code:
    ATPA := FloodFillTPA(pnts);
    for i := 0 to High(ATPA) do
        begin
          p := ATPA[i].MidPnt;
          custommouse(p);
        end;

    PS: It's really difficult posting something with code from a phone.. Ugh

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Hi Hellzonee,

    Skimming through your code the first thing I noticed was this part:
    Simba Code:
    for i := 0 to High(Pnts) do
        begin
          ATPA := FloodFillTPA(pnts);
    Basically your creating a 2DPointArray for every single Pnts[..]. Try calling FloodFillTPA before instead, like so:
    Simba Code:
    ATPA := FloodFillTPA(pnts);
    for i := 0 to High(ATPA) do
        begin
          p := ATPA[i].MidPnt;
          custommouse(p);
        end;

    PS: It's really difficult posting something with code from a phone.. Ugh
    Thank you for the reply (odd how villavu doesn't send you a notification when someone replies to your own thread unless quoted)! I will try your suggestion.

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
  •