Results 1 to 9 of 9

Thread: How can I repeat until finding a DTM or Color?

  1. #1
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default How can I repeat until finding a DTM or Color?

    == HAS BEEN ANSWERED ==


    I'm working on a thieving script. Once you succesfully thieved a chest you have a chance that this message will pop up.



    I have already scripted my way that the script understands that the chest has been succesfully looted if that message doesn't pop up. But it blocks chatbox and Simba can no longer read it to check if it has been succesful.

    How can I repeat my script until it has found this message? I was thinking of using something with color or a DTM. But my attempts have resulted into failed compiling so I'm looking for some help. This is my starting so far.

    Simba Code:
    begin

    ActivateClient;
    SetUpSRL;
      repeat
        OpenChest;
          repeat
            CheckFail;
          until(FindChatBoxText('open', 7, clBlack)) or
               (FindChatBoxText('open', 8, clBlack))
      until(false)

    end.

    Thanks in advance.

    EDIT: here is the whole script so far
    Simba Code:
    program ReadText;
    {$i srl/srl.simba}

    Function OpenChest:Boolean;
    Var
      X, Y: Integer;

    begin
      X:=MSCX;
      Y:=MSCY;
      if FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']) then
        begin;
          Writeln('We found the chest');
          GetMousePos(X, Y);

          Case Random(4) of
            0: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            1: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            2: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            3: begin;
                 Mouse(X, Y, 5, 5, False);
                 WaitOption('Open', 300);
                  Writeln('We clicked the chest');
                 Wait(8000+random(1000));
               end;
          end;
        end;
    end;

    procedure GreenBox;
    Var
    X, Y:Integer;

    begin
    if FindColorSpiralTolerance(X, Y, 1137204, 220, 457, 298, 479, 20) then
      begin
        MMouse(x, y, 5, 5);
        Mouse(x, y, 0, 0, True);
        Wait(1500+random(1000));
      end;
    end;


    function CheckFail:Boolean;
    Var
      X, Y: Integer;

    begin
      if(FindChatBoxText('fail', 8, clBlack)) then
        begin;
          Writeln('We failed to open the chest, trying again');
          FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']);
          GetMousePos(X, Y);
        end;

      if(FindChatBoxText('fail', 8, clBlack)) then

        Case Random(2) of
          0: begin;
               Mouse(X, Y, 5, 5, True);
               Writeln('We clicked the chest');
               Wait(8000+random(1000));
             end;

          1: begin;
               Mouse(X, Y, 5, 5, False);
               WaitOption('Open', 300);
               Writeln('We clicked the chest');
               Wait(8000+random(1000));
             end;
        end;
    end;

    begin

    ActivateClient;
    SetUpSRL;
      repeat
        OpenChest;
          repeat
            CheckFail;
          until(FindChatBoxText('open', 7, clBlack)) or
               (FindChatBoxText('open', 8, clBlack))
      until(false)

    end.
    If anyone has tips to make the script shorter it would be appreciated aswell.
    Last edited by J J; 02-28-2012 at 08:50 PM.

    Script source code available here: Github

  2. #2
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    You could use my through DTM which is a DTM of the green box. And repeat until you find that DTM in the chat box.

    I can post it here if you wish

  3. #3
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Quote Originally Posted by tehq View Post
    You could use my through DTM which is a DTM of the green box. And repeat until you find that DTM in the chat box.

    I can post it here if you wish
    I was thinking of using something similiar like that. However, if I add it to the repeating loop it won't compile because I haven't defined X and Y.

    Can you add it to my script and post it?

    Script source code available here: Github

  4. #4
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by RuneScapeJJ View Post
    I was thinking of using something similiar like that. However, if I add it to the repeating loop it won't compile because I haven't defined X and Y.

    Can you add it to my script and post it?
    Just did this very quick so you should check it (not sure if i put it in the loop you wanted me to )

    Simba Code:
    program ReadText;
    {$i srl/srl.simba}

    var
    X, Y, ThroughDTM: Integer;


    Procedure LoadDTM;

    begin

      ThroughDTM := DTMFromString('mbQAAAHicY2VgYFjAzMBwAogbgbgBiE8C8TwmBoZpULwEiq2TRRgYmZgZ8sJsGMrCLRguXrzIgA0wYsFgAAA+hQuY');

    end;
    Function OpenChest:Boolean;
    Var
      X, Y: Integer;

    begin
      X:=MSCX;
      Y:=MSCY;
      if FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']) then
        begin;
          Writeln('We found the chest');
          GetMousePos(X, Y);

          Case Random(4) of
            0: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            1: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            2: begin;
                  Mouse(X, Y, 5, 5, True);
                  Writeln('We clicked the chest');
                  Wait(8000+random(1000));
                end;

            3: begin;
                 Mouse(X, Y, 5, 5, False);
                 WaitOption('Open', 300);
                  Writeln('We clicked the chest');
                 Wait(8000+random(1000));
               end;
          end;
        end;
    end;

    procedure GreenBox;
    Var
    X, Y:Integer;

    begin
    if FindColorSpiralTolerance(X, Y, 1137204, 220, 457, 298, 479, 20) then
      begin
        MMouse(x, y, 5, 5);
        Mouse(x, y, 0, 0, True);
        Wait(1500+random(1000));
      end;
    end;


    function CheckFail:Boolean;
    Var
      X, Y: Integer;

    begin
      if(FindChatBoxText('fail', 8, clBlack)) then
        begin;
          Writeln('We failed to open the chest, trying again');
          FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']);
          GetMousePos(X, Y);
        end;

      if(FindChatBoxText('fail', 8, clBlack)) then

        Case Random(2) of
          0: begin;
               Mouse(X, Y, 5, 5, True);
               Writeln('We clicked the chest');
               Wait(8000+random(1000));
             end;

          1: begin;
               Mouse(X, Y, 5, 5, False);
               WaitOption('Open', 300);
               Writeln('We clicked the chest');
               Wait(8000+random(1000));
             end;
        end;
    end;

    begin

    ActivateClient;
    SetUpSRL;
      repeat
        OpenChest;
        LoadDTM;
          repeat
            CheckFail;
          until(FindChatBoxText('open', 7, clBlack) or FindDTM(ThroughDTM, x, y, MCX1, MCY1, MCX2, MCY2));
      until(false)
      FreeDTM(ThroughDTM);
    end.

  5. #5
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    I see. You basicly defined Var X, Y outside of a procedure/function. Which means that it can succesfully compile it at the loop at the end of the script? Because it was giving me an error with the X and Y at the repeat loop. I'll test it out right now. It did compile

    EDIT: Thanks, it works now.
    I think my own way would have worked if I defined the Var X, Y outside of my procedures/functions. Just right at the start. I'll test that out tomorrow to see if I understand it. Well this way works so now I can work on opening some jails. It's opening the chests flawless now (Thieving Guild).

    Thanks.
    Last edited by J J; 02-26-2012 at 10:10 PM.

    Script source code available here: Github

  6. #6
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by RuneScapeJJ View Post
    I see. You basicly defined Var X, Y outside of a procedure/function. Which means that it can succesfully compile it at the loop at the end of the script? Because it was giving me an error with the X and Y at the repeat loop. I'll test it out right now. It did compile

    EDIT: Thanks, it works now.
    I think my own way would have worked if I defined the Var X, Y outside of my procedures/functions. Just right at the start. I'll test that out tomorrow to see if I understand it. Well this way works so now I can work on opening some jails. It's opening the chests flawless now (Thieving Guild).

    Thanks.
    No problem, and good luck with this script!

  7. #7
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    But it blocks chatbox and Simba can no longer read it to check if it has been succesful.
    Simba Code:
    if FindText(x, y, 'hanky', UpChars, MCX1, MCY1, MCX2, MCY2) then // If find this message then...
    begin
          KeyDown(32);             // Press Space
          wait(10+random(40));
          KeyUp(32);
    end;

  8. #8
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why dont you just press spacebar if this appears? It's definitely something there in SRL, called ClickContinue?
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  9. #9
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Quote Originally Posted by nosaj.421 View Post
    Why dont you just press spacebar if this appears? It's definitely something there in SRL, called ClickContinue?
    Yes it has been posted above, but there is no need to waste time by clicking on something. It is just something as a failsafe to know that it did succesfully thieved the chest.

    Script source code available here: Github

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
  •