Results 1 to 7 of 7

Thread: A little wait function

  1. #1
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default A little wait function

    Nothing special; I just got fed up of writing + Random(x) and I'm sure many others do.

    Simba Code:
    {*******************************************************************************
    procedure RWait(Time, RTime : Integer; Minus : Boolean);
    by: Rich
    Description: Waits Time + random RTime. Maybe - random RTime if Minus set True
    *******************************************************************************}
         
    procedure RWait(Time, RTime : Integer; Minus : Boolean);
    begin
      Wait(Time + RandomRange(- (Integer(Minus) * RTime), RTime));
    end;

    I'll be honest I've not got my hopes up for this, but I thought I might as well post it.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

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

    Default

    Whats the point of minus?

    RWait(500, 75, 25, true)
    is exactly the same as
    RWait(500, 50, 0, false)
    every single time...

    -RM

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

  3. #3
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by Sir R. M8gic1an View Post
    Whats the point of minus?

    RWait(500, 75, 25, true)
    is exactly the same as
    RWait(500, 50, 0, false)
    every single time...

    -RM
    Not sure where that fourth parameter has come from.
    Having minus set as true gives the effect of
    Simba Code:
    + RandomRange(-RTime, RTime)
    whereas having it false does
    Simba Code:
    + Random(RTime)

    EDIT:
    Simba Code:
    program Test;
    var
      I : Integer;

    function RWait(Time, RTime : Integer; Minus : Boolean) : Integer;
    begin
      Result:=(Time + RandomRange(- (Integer(Minus) * RTime), RTime));
    end;

    begin
      WriteLn('Minus FALSE');
      for I:= 0 to 9 do
        WriteLn(RWait(5000, 2500, False));
      WriteLn('');
      WriteLn('');
      WriteLn('');
      WriteLn('Minus TRUE');
      for I:= 0 to 9 do
        WriteLn(RWait(5000, 2500, True));
    end.
    Run that and you get:
    Progress Report:
    Minus FALSE
    7360
    6214
    7470
    5257
    7150
    6051
    7484
    7185
    5645
    7056
    
    
    
    Minus TRUE
    2929
    6307
    6847
    5708
    3452
    7048
    7112
    3442
    4365
    4090
    Where the numbers would be the time waited. Notice with Minus as True that it has the chance to minus random RTime instead of just adding it on.
    Last edited by Rich; 10-28-2011 at 05:47 PM.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

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

    Default

    true, true, had misinterpreted it, sorry about that

    -RM

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

  5. #5
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    No problem
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  6. #6
    Join Date
    Aug 2007
    Location
    England
    Posts
    1,038
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Nothing special; I just got fed up of writing + Random(x) and I'm sure many others do.
    Me to, it ain't a big deal but will help out a lot as waits are a quite a big part of scripting. Less to right the better (I know I'm lazy lol).

    Nice job
    Today is the first day of the rest of your life

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Ehh I don't really think it has a place in SRL. People can just add it to their script if needed. I'm sure it's handy, though.

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
  •