Results 1 to 6 of 6

Thread: Why is this compiliing but not working?

  1. #1
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Post Why is this compiliing but not working?

    Simba Code:
    program new;
      {$Define SMART}
      {$I SRL/SRL.Simba}
      {$i srl/srl/misc/debug.simba}
      {$I SRL/SRL/MISC/SMARTGRAPHICS.SIMBA}

    procedure FindBanker;
    var
      TPA: Array of TPoint;
      ATPA: T2DPointArray;
      Box: TBox;
      TheCTS, I, X, Y, H : Integer;

    begin
      theCTS := GetToleranceSpeed;

      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(0.04, 0.40);

      FindColorsSpiralTolerance(301,175,TPA,11192042, MSX1, MSY1, MSX2, MSY2,6);
      ATPA := TPAToATPAEx(TPA, 40, 40);

      SetColorToleranceSpeed(theCTS);
      SetToleranceSpeed2Modifiers(0.02, 0.02);

      H := High(ATPA);
      If Length(ATPA) = 0 Then
        WriteLn('Length = O, Exiting FindBanker');
        Exit;
      For I := 0 To H Do
        begin
          WriteLn('FindBanker ATPA Length = ' + IntToStr (Length(ATPA)));
          //SortATPASize(ATPA,True);
          SortTPAFrom(TPA, Point(301,175));
          MiddleTPAEx(ATPA[I], X, Y);
          MMouse(x,y,4,2);
          Clickmouse2(mouse_right);
            if WaitOption('ank ',500) then
              begin
                WriteLn('We have found the Banker!');
                Wait(1000+random(500));
                break;
              end;
          end;
        debugatpabounds(atpa);
    end;

    begin
    setupSRL
      begin
        FindBanker;
        writeln('yay');
      end;
    end.

    Debug:
    Progress Report:
    Paired with SMART[20388]
    Failed to RSReady
    Failed to RSReady
    yay
    Successfully executed.


    Why will it not find the object or even say the length? I have debug for all outcomes and its not doing anything? Surely I am doing something wrong and I cannot see it. On another script it seems to work. Any help appreciated.
    You have permission to steal anything I've ever made...

  2. #2
    Join Date
    Mar 2010
    Posts
    152
    Mentioned
    1 Post(s)
    Quoted
    56 Post(s)

    Default

    I'm more than likely wrong as i'm new to scripting, but is it the lack of semi-colon after SetupSRL?

    I also noticed that;

    SortTPAFrom(TPA, Point(301,175));
    MiddleTPAEx(ATPA[I], X, Y)

    You're sorting a TPA and not an ATPA before sending MiddleTPAEX?

  3. #3
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    setupsrl();

    but maybe you need to add something more. like
    begin (stuff here) end ELSE (if not something found)
    begin
    writeln('not found')
    sleep(500)
    end

    so you know if its not found

  4. #4
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

    Default

    TK spotted it!
    If Length(ATPA) = 0 Then
    WriteLn('Length = O, Exiting FindBanker');
    Exit;

    missing begin end

  5. #5
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Quote Originally Posted by GREEN GIANT View Post
    I'm more than likely wrong as i'm new to scripting, but is it the lack of semi-colon after SetupSRL?

    I also noticed that;

    SortTPAFrom(TPA, Point(301,175));
    MiddleTPAEx(ATPA[I], X, Y)

    You're sorting a TPA and not an ATPA before sending MiddleTPAEX?
    You were right, always good to have another pair of eyes And I hadn't noticed that I'd left that bit in there. I had ended up going with sortatpasize though. Thanks a lot! Rep 4 u
    Quote Originally Posted by hoodz View Post
    setupsrl();

    but maybe you need to add something more. like
    begin (stuff here) end ELSE (if not something found)
    begin
    writeln('not found')
    sleep(500)
    end;

    so you know if its not found
    Well I do have similar things for that, let me show you:
    Simba Code:
    If Length(ATPA) = 0 Then
        WriteLn('Length = O, Exiting FindBanker');
        Exit;
    If there are no points found in the tpa it will debug that message.
    Simba Code:
    For I := 0 To H Do
        begin
          WriteLn('FindBanker ATPA Length = ' + IntToStr (Length(ATPA)));
    if it didn't display the earlier message, then it should be displaying this message (Which will write out the length of the atpa)

    Simba Code:
    if WaitOption('ank ',500) then
              begin
                WriteLn('We have found the Banker!');
                Wait(1000+random(500));
                break;
              end;
    If the text for the option I'm trying to find is found, then it says that it has been found, or else it would time out of the loop after cycling through the points without finding desired text, or it would have left after TPA length was 0.

    Your idea is still very good. I myself love debugging my script to know exactly where it went wrong so I can fine tune it.

    Happy scripting guys and thanks for the help.

    EDIT: @The Killer, I saw your post after posting this. I ended up seeing that shortly after posting this, but the setupsrl had eluded me.
    You have permission to steal anything I've ever made...

  6. #6
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

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
  •