Results 1 to 7 of 7

Thread: Until()..

  1. #1
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default Until()..

    People say that "Until(False)" is bad when you are repeating a main loop.

    I was wondering about the whole "Until(KeyIsDown)" or whatever one? What is it, so like it repeats until I press "F1" for example.
    Jus' Lurkin'

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Example:

    SCAR Code:
    Repeat
    writeLn('jjj');
    Until(IsKeyDown('s'));
    Closest i could get sorry .

  3. #3
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Repeat
      WriteLn('Thanks MasterKill');
    Until(IsFKeyDown(1))

  4. #4
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    Thanks
    Jus' Lurkin'

  5. #5
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Just to expand, until(false) is only bad when you don't have anything else to stop the script. Some people choose to do until(false) then have after every NextPlayer(false) a check to make sure there are still active players, such as:
    SCAR Code:
    NextPlayer(false);
      i := 0;
      while i < GetArrayLength(Players) do
        if Players[i].Active = True then
          Break
        else
          i := 1 + 1;
      if i >= GetArrayLength(Players) then
      begin
        Writeln('No more active players, terminating script');
        TerminateScript;
      end;
    So that goes through all the players checking if they are active and if one of them is, then it breaks the while loop, making the check afterwards false, thus not running it. However, if none of the players are active, then i will keep going until it is equal to or bigger than the number of players, then it will mean that there are no more players to check, and as i will then be equal to or bigger than the total players, it will mean that the check is returned true and the script is terminated with a Writeln to inform the user. Of course, it is quite long, so it will normally be put into a procedure like CusNextPlayFalse or something like that
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  6. #6
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    IsFKeyDown is not very stable ATM, sometimes it finds a key is down when it really is not... so be sure not to use in a script you want a 24+ hour proggy for


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  7. #7
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Why is it not stable? It only finds a key down if you recently pressed the key before running the function, then it doesn't recognize that it's down until you actually press it. So you'd have to do something like this:
    SCAR Code:
    program New;
    begin
      IsFKeyDown(2);
      while not IsFKeyDown(2) do
        wait(100);
    end.
    At least that's how it works for IsKeyDown...

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
  •