Results 1 to 4 of 4

Thread: Different wait functions

  1. #1
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default Different wait functions

    What are the differences and/or benefits of using -

    Simba Code:
    Wait(RandomRange(2000,2500));

    As opposed to -

    Simba Code:
    Wait(2000 + random(500));

    Also, I'm finding in more advanced scripts that the writer is using functions like -

    Simba Code:
    WaitUpTextMulti(['long', 'ong', 'bow'], 1000);

    Is there any value to using this function or others like it rather than simply inputting the function and one of the above wait times? Or does this simply save a line of code?

  2. #2
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    it saves lines, and makes scripting easier. It's also more effective than doing

    Simba Code:
    mmouse(x, y, 0, 0);
    wait(100 + random(200));
    if isuptext('blah') then

    because it might lag for others, where waituptext() is dynamic, if that makes sence
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Here are some I wrote.. It's a mix of everything but you can see how I write the wait functions. They work just as the ones you have above.


    The difference between doing:

    Simba Code:
    Wait(2000);   //Waits 2 seconds no matter what..
    isUptext('Walk here');

    versus

    Simba Code:
    WaitUptext('Walk here', 2000);  //Keeps searching for the uptext during the 2 seconds.. Timesout after 2 seconds.. If the uptext is found before 2 seconds is up, the function returns true. Thus it doesn't have to wait the entire 2 seconds every time.

    is that the first one will only try once.. if the uptext isn't found then it will not do whatever.. Whereas the second one will keep looking for the uptext during a set timer.. When that timeout has been reached, if the uptext isn't found, it will return false.

    Example:
    WaitUptext('Walk here', 2000); will keep searching for the uptext during those 2 seconds whereas
    Wait(2000);
    IsUptext('Walk here'); will search only once and after 2 seconds is up.




    These are included in SRL/Simba and allows you to keep trying a function during an interval.. Just like the waituptext:
    Simba Code:
    WaitFunc();
    WaitFuncEx();


    These are not in SRL/Simba:
    Simba Code:
    Function WaitAmount(Item, Amount, TimeToWait: Integer): Integer;
    var
      T, Count: integer;
    begin
      Count:= 0; Result:= 0;
      T := (GetSystemTime + TimeToWait);
      while (GetSystemTime < t) do
      begin
        Count:= ItemAmount('inv', 'dtm', Item, []);
        if (Count >= Amount) then
        begin
          Result:= Count;
          Break;
        end;
        Wait(50);
      end;
    end;

    Simba Code:
    Function WaitFindNPCTextMulti(Texts: TStringArray; Action: Fnct_ActionOptions; TimeToWait: Integer): Boolean;
    var
      T: integer;
    begin
      T := (GetSystemTime + TimeToWait);
      while (GetSystemTime < t) do
      begin
        if (FindNPCChatTextMulti(Texts, Action)) then
        begin
          Result:= True;
          Break;
        end;
        Wait(50);
      end;
    end;

    Simba Code:
    Function MixingInterface: Boolean;
    var
      Text: String;
      Bool: Boolean;
    begin
      Text:= GetTextAtExWrap(41, 345, 278, 362, 0, 5, 2, 16777215, 10, 'SmallChars');
      Bool:= ExecRegExpr('make', Text) or ExecRegExpr('wish to make', Text) or ExecRegExpr('wish | to | make', Text);

      If (Bool) then
      begin
        MouseBox(207, 398, 314, 460, MOUSE_MOVE);
        if (WaitUptextMulti(['ake', 'All', 'ke A'], 600)) then
        begin
          ClickMouse2(MOUSE_LEFT);
          Result:= True;
        end;
      end;
    end;

    Function WaitMixingInterface(TimeToWait: Integer): Boolean;
    var
      T: integer;
    begin
      T := (GetSystemTime + TimeToWait);
      while (GetSystemTime < t) do
      begin
        if (MixingInterface) then
        begin
          Result:= True;
          Break;
        end;
        Wait(50);
      end;
    end;

    Function ItemSelected(Item: Integer): Boolean;
    var
      X, Y, Slot: Integer;
    begin
      if (WaitFindDTM(X, Y, Item, 500)) then
      begin
        Slot:= CoordsToItem(X, Y);
        Result:= ItemActivated(Slot);
      end;
    end;

    Function AnyItemSelected: Integer;
    var
      I: Integer;
    begin
      Result:= 0;
      For I:= 1 To 28 do
      begin
        if (ItemActivated(I)) then
        begin
          Result:= I;
          break;
        end;
      end;
    end;

    Function WaitItemSelected(Item, TimeToWait: Integer): Boolean;
    var
      T: integer;
    begin
      T := (GetSystemTime + TimeToWait);
      while (GetSystemTime < t) do
      begin
        if (ItemSelected(Item)) then
        begin
          Result:= True;
          Break;
        end;
        Wait(50);
      end;
    end;

    Simba Code:
    Function FindDTMSlot(var X, Y: Integer; DTM, Slot: Integer): Boolean;
    Var
      Bounds: TBox;
    begin
      Bounds:= InvBox(Slot);
      Result:= FindDTM(DTM, X, Y, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2);
    end;

    Simba Code:
    Function WaitGameTab(Tab, TimeToWait: Integer): Boolean;
    Var
      T: Integer;
    begin
      Result := False;
      T := GetSystemTime + TimeToWait;
      while (GetSystemTime < T) do
      begin
        if (GetCurrentTab = Tab) then
        begin
          Result := True;
          Exit;
        end;
        Wait(20 + Random(10));
      end;
    end;

  4. #4
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Excellent! Thanks so much for your help, both of you.
    It had really been bugging me, because to my eye there was no difference but clearly given the more able scripters prefer these functions there had to be a reason why

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
  •