Page 2 of 2 FirstFirst 12
Results 26 to 32 of 32

Thread: WaitUptext() and WaitOption()

  1. #26
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Should be added, but It should be made into Multi functions.. Like this

    SCAR Code:
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := OptionsExist(S, False);
        Wait(10+Random(10));
      until(Result)or(GetSystemTime > T);
      Result := ChooseOptionMulti(S);
    end;


    Function WaitOption(S: String; Time: Integer): Boolean;
    begin
      Result := WaitOptionMulti([S], Time);
    end;


    Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := IsUpTextMultiCustom(S);
        Wait(10+Random(10));
      until(Result)or(GetSystemTime > T);
    end;


    Function WaitUptext(S: String; Time: Integer): Boolean;
    begin
      Result := WaitUptextMulti([S], Time);
    end;

    Otherwise the "Multi" functions will just end up being added later on..
    Last edited by Naike; 06-22-2009 at 05:30 AM.

  2. #27
    Join Date
    May 2007
    Location
    Sydney, Australia (Faggot Region)
    Posts
    1,465
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    N1ke is a beast.


  3. #28
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               ยป Waiting Routines                            --//
    //-----------------------------------------------------------------//
    // * Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // By Marpis & N1ke! & Rasta Magician
    // * Function WaitOption(S: String; Time: Integer): Boolean;            // By Marpis edited by N1ke!
    // * Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean; // By Marpis & N1ke!
    // * Function WaitUptext(S: String; Time: Integer): Boolean;            // By Marpis edited by N1ke!
    // * Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;   // By Rasta Magician
    // * Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean; // By Rasta Magician


    {*******************************************************************************
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    By: Marpis & N1ke! & Rasta Magician
    Description: Waits for a TStringArray of options and selects one of them
    *******************************************************************************}

    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    var
      T, a, b, c: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := OptionsExist(S, True);
        Wait(10+Random(10));
      until(Result)or(GetSystemTime > T);
      //from Mouse, but to be faster so we don't call GetMousePos twice.
      Wait(60 + Random(30));
      GetMousePos(b, c);
      HoldMouse(b, c, left);
      repeat
        Wait(20 + Random(30));
        a := a + 1;
      until (a > 4);
      GetMousePos(b, c);
      ReleaseMouse(b, c, left);
      Wait(100 + Random(100));
    end;


    {*******************************************************************************
    Function WaitOption(S: String; Time: Integer): Boolean;
    By: Marpis edited by N1ke!
    Description: Waits for an Option and selects it
    *******************************************************************************}

    Function WaitOption(S: String; Time: Integer): Boolean;
    begin
      Result := WaitOptionMulti([S], Time);
    end;

    {*******************************************************************************
    Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;
    By: Marpis & N1ke!
    Description: Waits for a TStringArray of UpText, returns true if found
    *******************************************************************************}

    Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := IsUpTextMultiCustom(S);
        Wait(10+Random(10));
      until(Result)or(GetSystemTime > T);
    end;

    {*******************************************************************************
    Function WaitUptext(S: String; Time: Integer): Boolean;
    By: Marpis edited by N1ke!
    Description: Waits for an UpText, returns true if found
    *******************************************************************************}

    Function WaitUptext(S: String; Time: Integer): Boolean;
    begin
      Result := WaitUptextMulti([S], Time);
    end;

    {*******************************************************************************
    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    By: Rasta Magician
    Description: Waits for a color at (x, y) with tolerance Tol, returns true if found
    *******************************************************************************}

    Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
    var
      Time: integer;
    begin
      Time := GetSystemTime;
      while GetSystemTime - Time < MaxTime do
        if SimilarColors(GetColor(x, y), Color, Tol) then
        begin
          Result := true;
          exit;
        end;
    end;

    {*******************************************************************************
    Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean;
    By: Rasta Magician
    Description: Waits Color count in box (x1, y1, x2, y2) with Tol
    *******************************************************************************}

    Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean;
    var
      Time: integer;
      TPA: TPointArray;
    begin
      Time := GetSystemTime;
      while GetSystemTime - Time < MaxTime do
        if FindColorsTolerance(TPA, Color, x1, y1, x2, y2, Tol) then
          if InRange(Length(TPA), MinCount, MaxCount) then
          begin
            Result := true;
            exit;
          end;
    end;

    Waiting.scar being discussed in devs.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  4. #29
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    SCAR Code:
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    var
      T, a, b, c: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := OptionsExist(S, True);
        Wait(10+Random(10));
      until(Result)or(GetSystemTime > T);
      //from Mouse, but to be faster so we don't call GetMousePos twice.
      Wait(60 + Random(30));
      GetMousePos(b, c);
      HoldMouse(b, c, left);
      repeat
        Wait(20 + Random(30));
        a := a + 1;
      until (a > 4);
      GetMousePos(b, c);
      ReleaseMouse(b, c, left);
      Wait(100 + Random(100));
    end;
    you forgot "if result then" ?

    why not just use chooseoption? you should use chooseoption even if the option was not found, because chooseoption moves the mouse away making the optionbox disappear, and that is what we want, no?

  5. #30
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    you forgot "if result then" ?

    why not just use chooseoption? you should use chooseoption even if the option was not found, because chooseoption moves the mouse away making the optionbox disappear, and that is what we want, no?
    I ended up re-writting it, because OptionsExist and ChooseOption are basically the same thing except for the clicking, but the detection is all the same.

    so it just simply chooses option

    SCAR Code:
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    By: Marpis & N1ke! & Rasta Magician
    Description: Waits for a TStringArray of options and selects one of them
    *******************************************************************************}
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    var
      T, a, b, c: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := ChooseOptionMultiEx(S, 'all', ClickLeft);
        Wait(30+Random(10));
      until(Result)or(GetSystemTime > T)
    end;

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  6. #31
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    I ended up re-writting it, because OptionsExist and ChooseOption are basically the same thing except for the clicking, but the detection is all the same.

    so it just simply chooses option

    SCAR Code:
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    By: Marpis & N1ke! & Rasta Magician
    Description: Waits for a TStringArray of options and selects one of them
    *******************************************************************************}
    Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
    var
      T, a, b, c: Integer;
    begin
      T := GetSystemTime + Time;
      repeat
        Result := ChooseOptionMultiEx(S, 'all', ClickLeft);
        Wait(30+Random(10));
      until(Result)or(GetSystemTime > T)
    end;

    ~RM
    doesn't ChooseOptionMultiEx move the mouse away closing the optionbox if the option wasn't found? because ChooseOption does. If so, then that will check only once if the option is there, then move the mouse away and continue the loop.

    plus, no use for 30+random(10), it could as well be 1+random(10) because the randomness will be the same but less waiting

  7. #32
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    doesn't ChooseOptionMultiEx move the mouse away closing the optionbox if the option wasn't found? because ChooseOption does. If so, then that will check only once if the option is there, then move the mouse away and continue the loop.

    plus, no use for 30+random(10), it could as well be 1+random(10) because the randomness will be the same but less waiting
    if it was 1+random(10) it would call random(10) more often than if it were 30 + random(10), therefore making a difference

    Also, i've been using WaitChooseOption, so i know it works. if the box is not open then it won't search for the option, exiting immediately, so it'll continue if the loop until the box is open, and only then will it actually search for the text. if the text is not there then it is not an option. Also, just fyi, chooseOption calls ChooseOptionsMultiEx

    also, added to svn in timing.scar , check tut island for the tutorial in the new "Newly Added to SRL" section

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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