Results 1 to 6 of 6

Thread: Wait Times

  1. #1
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default Wait Times

    So I've been using wait(Integer) a lot in my scripts to wait for a screen to close or an area to load, and it seems pretty inefficient. What are some better methods for detecting changes in the environment? I'm thinking about scanning for a color in the chatbox maybe, but I'd like some ideas please!

  2. #2
    Join Date
    Apr 2015
    Location
    FireFox
    Posts
    528
    Mentioned
    10 Post(s)
    Quoted
    227 Post(s)

    Default

    Have you looked over here? http://docs.villavu.com/srl-6/index.html
    Scripting with ogLib

  3. #3
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by swaggle_pants View Post
    So I've been using wait(Integer) a lot in my scripts to wait for a screen to close or an area to load, and it seems pretty inefficient. What are some better methods for detecting changes in the environment? I'm thinking about scanning for a color in the chatbox maybe, but I'd like some ideas please!
    Depends on what change you are trying to detect. If you're waiting for say, the bank screen to close, you can use waitTypeFunc, which will automatically put in a timeout failsafe for you. All the SRL-6 .isOpen functions can be used like this (bankscreen.isOpen, beastOfBurden.isOpen, etc).

    waitFunc and waitTypeFunc runs a function over and over until it returns true, or the timeout expires.

    If there's not an SRL-6 function, you can create your own custom function to detect an environment change, and this function will completely vary, so an example of what you're trying to detect would be great. Then you can use waitFunc like so:

    Simba Code:
    function environmentChange(): boolean;
    begin
    //your detection
    if blahblahChanged then
      exit(true)
    else
      exit(false);
    end;
    {...}
    //somewhere else in the script
    waitFunc(@environmentChange, 100 + random(100), 10000);

    That code will run environmentChange() every 100 + random(100) ms, until 10000ms have elapsed OR it returns true.

    If you are trying to detect "Loading - please wait" then @HKbotz created these helpful functions awhile back: https://villavu.com/forum/showthread.php?t=111436
    Last edited by Clarity; 06-30-2015 at 02:17 PM.

  4. #4
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Thank you that is very helpful. Also what is the @ operator for?

  5. #5
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by swaggle_pants View Post
    Thank you that is very helpful. Also what is the @ operator for?
    It is a function pointer indicator. It denotes a place in script memory (like a function or procedure), rather than a variable value.

    @Kevin wrote a tutorial here: https://villavu.com/forum/showthread.php?t=102800

    e.g.

    Simba Code:
    procedure doSomething;
    begin
    {...}
    end;

    procedure doSomethingElse;
    begin
    {...}
    end;

    procedure mainLoop;
    var
      myReaction: procedure();
    begin
      if thisHappens then
        myReaction := @doSomething
      else if thatHappens then
        myReaction := @doSomethingElse;

      myReaction();
    end;
    Last edited by Clarity; 06-30-2015 at 06:06 PM.

  6. #6
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    So whats the difference between just called it, doSomething() as opposed to using the pointer @doSomething

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
  •