Results 1 to 18 of 18

Thread: While Do Loop Question

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default While Do Loop Question

    Let's say you got

    Simba Code:
    While Ugly Do
    Begin
      Shower;
      Shave;
      Makeup;
      //Let's say you turn pretty here (Ugly=False)
      DressSkanky;
    End;

    Once Ugly=False would the loop stop?
    Or would it complete the ENTIRE loop (as in DessSkanky) before stopping even if you turned pretty in the middle of the loop?

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    The condition is only checked at the top of the loop (i.e. before each iteration). In your example, DressSkanky would be executed before the program exited that loop.
    :-)

  3. #3
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Damn.
    Check this out here Method:
    http://villavu.com/forum/showthread....935#post845935

    Since it doesn't work well in SMART I want to do something like

    Simba Code:
    While Not GameTab=25 Do
          Begin
            KeyDown(VK_F1);
            Wait(100 + Random(100));
            KeyUp(VK_F1);
            Wait(1000+Random(500));
          End;

    Problem being, I don't want that extra wait right there to happen IF we are in the correct gametab. I like my script to be fast and optimized.
    I guess before the wait I could just put If GameTab=25 Then Break and that would work fine?

    Get me? Any better way or is this just fine?

  4. #4
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Since when was there a wile loop?

    (I felt like trolololol'ing)

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  5. #5
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Answer my latest post ^?

  6. #6
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Answer my latest post ^?
    if not ugly then break...
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  7. #7
    Join Date
    Nov 2011
    Location
    Behind a rock
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't know this language but will look at it soon, but there must be some sort of Break statement. Do While loops executes the code first then it checks the condition/
    Code:
    0100011101110010011010010110010101100110001000000101001101100101011001010110010001110011

  8. #8
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Thanks buddy, yeah I have it break in the middle of the code in my condition is satisfied.

  9. #9
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Simba Code:
    function FKeyGameTab(Tab: Integer): Boolean;
    var
      T, Key: Integer;
    begin
      case Tab of
        tab_Inv: Key := VK_F1;
        tab_Equip: Key := VK_F2;
        tab_Prayer: Key := VK_F3;
        tab_Magic: Key := VK_F4;
        tab_Equip: Key := VK_F5;
      else
        begin
          srl_Warn('FKeyGameTab', 'tab was not valid to fkey to. Using gametab instead.', warn_AllVersions);
          Result := GameTab(Tab);
          Exit;
        end;
      end;
      T := GetSystemTime + 3000;
      KeyDown(Key);
      while not(Result) and (T <= GetSystemTime) do
      begin
        Wait(100 + Random(50));
        Result := (GetCurrentTab = Tab);
      end;
      KeyUp(Key);
      Wait(100 + Random(50));
    end;
    I've used this

  10. #10
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Is that in SRL already, or did someone just whip that up?
    Does it work with SMART properly? I think yes because the while do. Cool thanks.

  11. #11
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Is that in SRL already, or did someone just whip that up?
    Does it work with SMART properly? I think yes because the while do. Cool thanks.
    Me.

  12. #12
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    Me.
    Make a post in the SRL Additions forum, I'm sure it would be accepted.

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

    Default

    Looks neat, if it works in both SMART and the browser (which I'm assuming it does) I'd love to add it to SRL.

  14. #14
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    I think its already in SRL.. >.>
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  15. #15
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    I think its already in SRL.. >.>
    I couldn't find it(fkey-tab function thing)...
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  16. #16
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    It shouldn't be because I wrote it

  17. #17
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    It shouldn't be because I wrote it
    Your version presses presses fkey and waits until you are in the correct gametab and then releases the key. Wouldn't it be more human-like to pres it, release it and then wait until you are in the correct gametab.

    I personally never hold the key until the correct gametab. I just press it quickly and wait for it to open.

    Also your version would press the key even when you already are in the correct gametab.
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

  18. #18
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    ^Agree with Annti.
    <3 You though Tom, thanks for the idea!

    Annti, the one I ended up writing basically does that (no fail safe for if that tab is (for some off reason) never reached though, but it waits 500+Random(500) after each press before pressing again.

    Simba Code:
    Begin
         While (Not(GetCurrentTab=25)) Do
          Begin
            KeyDown(VK_F1);
            Wait(100 + Random(100));
            KeyUp(VK_F1);
            If GetCurrentTab=25 Then Break;
            Wait(500+Random(500));
          End;
        End;

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
  •