Results 1 to 17 of 17

Thread: Infinite Loop possibly?

  1. #1
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default Infinite Loop possibly?

    Im making a script to mine and bank clay at Ardounge (Was running fine till I made a change to speed it up)

    I want the script to walk to the bank, then bank the clay. If it starts in the bank, it banks fine, if it has to go to the walking procedure, it gets stuck.

    So Ive narrowed it down to the procedure that causes issues

    Simba Code:
    Procedure GetIntoBank;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
      i, L: Integer;
      P: TPoint;

    begin
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
      if FindColorsSpiralTolerance(X, Y, TPA, 8618893 , MMX1, MMY1, MMX2, MMY2, 3) then
      begin
        ATPA := TPAtoATPAEx(TPA, 10, 10);
        SortATPAFromFirstPoint(ATPA, Point(690, 93));
        //DebugATPA(ATPA, '');
        L:=High(ATPA)
        for i:=0 to L do
        if GetArrayLength(ATPA[i]) > 5 then
          begin
              P := MiddleTPA(ATPA[i]);
              Mouse(P.x, P.y, 3, 3, True);
              wait(RandomRange(250,300));
              FFlag(1);
            end;
          end;
      end;

    The script should click one of the lighter colored tiles in the bank, then wait until the flag is gone and exit, and continue to bank, but sometimes it will click more than once, other times it will then just stop at this point.

    Main Loop :

    Simba Code:
    begin
      Setup;
      repeat
        while not LoggedIn do
        repeat
          LogInPlayer;
        until(LoggedIn);
        if (not InvFull and not AtRocks) then
          WalkToRocks;
        if (not InvFull and AtRocks) then
          MineRocks;
        if (InvFull and AtBank) then
          DoBanking;
        if (InvFull and not AtBank) then
          WalkToBank;
      until(False);
    end.

    Walking to Bank Procedure:

    Simba Code:
    function WalkToBank: Boolean;
    var
      ToBank: TPointArray;
    begin
    FindNormalRandoms;
      ToBank :=[Point(272,156),Point(272,166),Point(272,174),Point(270,187),Point(265,202),Point(261,218),Point(258,230),Point(247,245),Point(239,260),Point(231,276),Point(227,284),Point(222,301),Point(216,307),Point(205,312),Point(194,320),Point(188,331),Point(184,343),Point(188,347)];
      if SPS_WalkPath(ToBank) then
      begin
      FindNormalRandoms;
        GetIntoBank;
        result := True;
        Status := 'At the bank';
        Writeln('Status:' + Status);
        exit;
      end
      else
      begin
      FindNormalRandoms;
        Status := 'Did not walk to the bank, shutting down.';
        Writeln('Status:' + Status);
        result := false;
        TerminateScript;
      end;
    end;

    So how do I get it to continue past this? Everything was working until I added GetIntoBank as a procedure, ideas?

  2. #2
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    try adding exit; after fflag(1);
    also you don't have a failsafe incase
    Simba Code:
    if GetArrayLength(ATPA[i]) > 5 then
    is always false

  3. #3
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    try adding exit; after fflag(1);
    also you don't have a failsafe incase
    Simba Code:
    if GetArrayLength(ATPA[i]) > 5 then
    is always false
    Ill add those in, see if it does anything, I forgot I made that par a if then

  4. #4
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Doesnt change anything/:

  5. #5
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Use writelns' EVERYWHERE. Get down to exactly where it gets stuck.

  6. #6
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Use writelns' EVERYWHERE. Get down to exactly where it gets stuck.

    It gets stuck right after the GetIntoBank procedure I just wanted to post where I use it :P

    E* It never exits to the next procedure after GetIntoBank, which should be Banking in the mainloop.

  7. #7
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Can you tell me which line it stops at? Post the code, and bold the line.

  8. #8
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    I would revise your ACA picked CTS 2 colors, seeing as you have no hue or sat modifiers (only 0.00 x2).

    Best bet for a banker would be the suite / clothing they wear (Granted exceptions for custom bank spots).

    To help see what's going on, I'd suggest including this:
    Simba Code:
    {$include_once srl/srl/misc/debug.simba}

    So you can find the colors, get the TPA, debug the TPA with DebugTPA(TPA, '');.
    This will show you what points are retrieved from the TPA searched.

    Then after you pick up a good amount of the colors with the TPA finding, I'd Split the TPA into an ATPA as you have, but again (like with the TPA) calling DebugATPA(ATPA, ''); and stopping again, looking at what parts are split up from the TPA, making the ATPA.

    Then! Then you can say something like, "well I notice the Banker ATPA has a big blob (aka an index containing a TPA), the biggest on the Screen!" If this is indeed the case, trying something like SortATPASize(ATPA, True); the ATPA will be sorted from Biggest TPA to smallest TPA (note the TPA's make up the ATPA). Then when you loop through the ATPA, you will most likely hit the best TPA right off the start! :]

    Cheers,
    Le Jingle

  9. #9
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Can you tell me which line it stops at? Post the code, and bold the line.

    Simba Code:
    Procedure GetIntoBank;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
      i, L: Integer;
      P: TPoint;

    begin
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
      if FindColorsSpiralTolerance(X, Y, TPA, 8618893 , MMX1, MMY1, MMX2, MMY2, 3) then
      begin
        ATPA := TPAtoATPAEx(TPA, 10, 10);
        SortATPAFromFirstPoint(ATPA, Point(690, 93));
        //DebugATPA(ATPA, '');
        L:=High(ATPA)
        for i:=0 to L do
        if GetArrayLength(ATPA[i]) > 5 then
          begin
              P := MiddleTPA(ATPA[i]);
              Mouse(P.x, P.y, 3, 3, True);
              [B]wait(RandomRange(250,300)); // It stops after this, it gets all the way through the procedure, but sometimes
              FFlag(1);[/B] // it will click another spot twice, like it repeats
            end;            // Most of the time, it will complete this, open the main inventory then sit with the cursor on the main
          end;              // inventory button.
      end;

  10. #10
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    I would revise your ACA picked CTS 2 colors, seeing as you have no hue or sat modifiers (only 0.00 x2).

    Best bet for a banker would be the suite / clothing they wear (Granted exceptions for custom bank spots).

    To help see what's going on, I'd suggest including this:
    Simba Code:
    {$include_once srl/srl/misc/debug.simba}

    So you can find the colors, get the TPA, debug the TPA with DebugTPA(TPA, '');.
    This will show you what points are retrieved from the TPA searched.

    Then after you pick up a good amount of the colors with the TPA finding, I'd Split the TPA into an ATPA as you have, but again (like with the TPA) calling DebugATPA(ATPA, ''); and stopping again, looking at what parts are split up from the TPA, making the ATPA.

    Then! Then you can say something like, "well I notice the Banker ATPA has a big blob (aka an index containing a TPA), the biggest on the Screen!" If this is indeed the case, trying something like SortATPASize(ATPA, True); the ATPA will be sorted from Biggest TPA to smallest TPA (note the TPA's make up the ATPA). Then when you loop through the ATPA, you will most likely hit the best TPA right off the start! :]

    Cheers,
    Le Jingle

    The 0.00 colors are for the MM, its the grey bank tile in the bank (Lighter colored one, ACA gives no hue/sat mods) I have a slight tolerance on it, but it never actually misses the color on the MM

  11. #11
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    As far as I can tell, it's either your for loop (to value might be messing it up) or FFlag(); is screwing up.
    Try experimenting with FFlag values.

  12. #12
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    You used a loop here:
    Simba Code:
    for i:=0 to L do
    which is why it sometimes repeat and click on another spot. So Exit/Break after FFlag().

    Is the MM flag still on screen when the script gets stuck?
    Also try adding a writeln() after FFlag() and see if that's executed.

  13. #13
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    You used a loop here:
    Simba Code:
    for i:=0 to L do
    which is why it sometimes repeat and click on another spot. So Exit/Break after FFlag().



    Is the MM flag still on screen when the script gets stuck?
    Also try adding a writeln() after FFlag() and see if that's executed.
    It does it with and without FFlag (I tried jsut using a while ismoving do wait(randomrange(25,50)) but that did stop my looping! Ill check the FFlag!

    I'd be more than willing to Pm any members the fullscript plus SPS maps if that would help!

  14. #14
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    I used writeln's it gets through the get into bank procedure, but never starts banking, just sits there @Sin

  15. #15
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    Did you try adding Exit; after FFlag(1)?

  16. #16
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    If you click in a non walkable zone on rs the flag will stay there forever, so i guess your doing that?

  17. #17
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    If you click in a non walkable zone on rs the flag will stay there forever, so i guess your doing that?
    I fixed it, FindNormal randoms was making it wait for like 4525454545 seconds, @Justin Please close, fixed! Thanks guys!

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
  •