Results 1 to 4 of 4

Thread: WaitFunc Modification

  1. #1
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default WaitFunc Modification

    This makes the WaitFunc wait until the function is either true or false depending on what the scripter wants.
    SCAR Code:
    function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer; WaitTrue:Boolean): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + MaxTime;
      while (GetSystemTime < T) do
      begin
        if (Func()) xor Not(WaitTrue) then
        begin
          Result := True;
          Exit;
        end;
        Wait(WaitPerLoop);
      end;
    end;

  2. #2
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    I never saw the coding to that function, so I never knew how to make a function be a parameter, that's pretty cool, I wanna try making a function that calls a function.

    And what did the old function look like? Just wondering how the two look in comparison with eachother.

  3. #3
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    the
    if (func()) xor not(WaitTrue) then
    Was actually just....
    if (func()) then
    small mod ,but allows for variety of extra things...
    ALSO would this have too many issues, ie

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

    Default

    http://villavu.com/forum/showthread.php?t=46915

    SCAR Code:
    {*******************************************************************************
    function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
    By: Rasta Magician, small edit by EvilChicken!
    Description: Waits for function Func to be true. WaitPerLoop is how often you
    want to call "Func" function.
    Example: "WaitFunc(@BankScreen, 10 + Random(15), 750);" will check if BankScreen
    is open every 10-25th millisecond, for a maximum of 750 milliseconds.
    Notice the '@'.
    *******************************************************************************}

    function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + MaxTime;
      while (GetSystemTime < T) do
      begin
        //to implement this idea...
        if (Func() = WaitTrue) then
        //if (Func()) then
        begin
          Result := True;
          Exit;
        end;
        Wait(WaitPerLoop);
      end;
    end;

    I like the idea, it'll most likely be implemented, only differently.

    ~RM

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

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
  •