Results 1 to 9 of 9

Thread: Help with loop?

  1. #1
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Unhappy Help with loop?

    I know the basics of a loop, such as every "repeat;" must have an until() and where to put them. If I want to make a loop continue until I press, say, the X letter key, then what would I put in the Until()?
    ~Zeek
    Last major script: November 2009
    Attempted to rejoin: January 2011
    Rejoining: [][][][][]
    Current task: writing basic alching script

  2. #2
    Join Date
    Jan 2009
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmmm try

    Code:
    repeat
       //Code Here
    until IsKeyDown('x')
    EDIT: Yep, that works, just checked it.
    Last edited by superbatman; 03-28-2009 at 07:33 PM.

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

    Default

    [offtopic]Superbatman, try using [scar ] tags, they are nicer to read
    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

  4. #4
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, thanks!
    ~Zeek
    Last major script: November 2009
    Attempted to rejoin: January 2011
    Rejoining: [][][][][]
    Current task: writing basic alching script

  5. #5
    Join Date
    Jan 2009
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oo thanks nava. I used to push the little tractor icon in the corner, but its gone now

  6. #6
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, so it doesn't stop at the Until(), it loops over and over again...
    Here's me using it in a simple script...
    SCAR Code:
    program New;
    begin
      repeat
        WriteLn('Press X to make me stop appearing');
        Wait(2500+random(500));
      until IsKeyDown('X')
    end.

    And here's my result:
    Code:
    Successfully compiled (46 ms)
    Press X to make me stop appearing
    Press X to make me stop appearing
    Press X to make me stop appearing
    Press X to make me stop appearing
    Press X to make me stop appearing
    Press X to make me stop appearing
    Successfully executed
    I made it stop with Ctrl-F4... Whenever I hit X it just types it into the script area.
    ~Zeek
    Last major script: November 2009
    Attempted to rejoin: January 2011
    Rejoining: [][][][][]
    Current task: writing basic alching script

  7. #7
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Your script can only check if X is pressed everytime is reaches that point. While waiting it won't check if X is pressed.
    That means you have to hold down the X button in a couple of seconds.

  8. #8
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Your script can only check if X is pressed everytime is reaches that point. While waiting it won't check if X is pressed.
    That means you have to hold down the X button in a couple of seconds.
    Just what i wanted to say.. D:

    But, here's an easier way to do it:
    Code:
    program New;
    begin
    while not IsKeyDown('X') do//While the 'X' key is not pressed
    Wait(50);//It will wait.
    end.
    Woot woot.

  9. #9
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah! Epiphany.
    Thanks, all.
    ~Zeek
    Last major script: November 2009
    Attempted to rejoin: January 2011
    Rejoining: [][][][][]
    Current task: writing basic alching script

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
  •