Results 1 to 11 of 11

Thread: Basic Loop Question.

  1. #1
    Join Date
    Apr 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Basic Loop Question.

    Well I have completed my script, it's not for runescape but it's another RPG.

    Basically I coded the whole thing and it picks 5 wheat plants then stops, but I want it to constantly do them over and over and over. How do I set a loop so it does my WHOLE SCRIPT over and over?

  2. #2
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Raepor View Post
    Well I have completed my script, it's not for runescape but it's another RPG.


    Basically I coded the whole thing and it picks 5 wheat plants then stops, but I want it to constantly do them over and over and over. How do I set a loop so it does my WHOLE SCRIPT over and over?
    SCAR Code:
    program MainLoop;
    Var
    i:integer//declares i as an integer (duh)
    begin
    i:=0//says what i is
    repeat
    i:=i+1//adds 1 to i every time and keeps track of it so it isnt an infinite loop =D
    //blah blah blah
    //more blahs
    //w/e
    //mhm....
    //yadayada
    until
    i>=(50)//however many times you want it done
    end.

    Should give you an idea on how to do it, oh and you can use a constant at the beggining to make it easier so you dont have to input it whereever it is in your script buy doing
    SCAR Code:
    Const
    timestodo=//howevery many times you want it done
    var
    i:integer//declares i as an integer (duh)
    begin
    i:=0//says what i is
    repeat
    i:=i+1//adds 1 to i every time and keeps track of it so it isnt an infinite loop =D
    //blah blah blah
    //more blahs
    //w/e
    //mhm....
    //yadayada
    until
    i>=(timestodo)
    end.

  3. #3
    Join Date
    Apr 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    another cool thing...

    You can also use
    SCAR Code:
    repeat

    until(false);

    to repeat infinitely, but i dont recommend getting into the habbit of that unless it is absolutely necessary. You can also break the loop early with exit; or break; combined with a condition like if. Good luck on your script!

  4. #4
    Join Date
    Apr 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    None of these work, yet again im trying to make my WHOLE SCRIPT repeat itself. Not just 1 procedure/function, I mean all 10 of the procedures I have i want it to repeat them in order in which they are in.

    Thanks for the feedback though.

  5. #5
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Raepor View Post
    None of these work, yet again im trying to make my WHOLE SCRIPT repeat itself. Not just 1 procedure/function, I mean all 10 of the procedures I have i want it to repeat them in order in which they are in.

    Thanks for the feedback though.
    send me the script ill explain it more.

  6. #6
    Join Date
    Apr 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Do this....
    SCAR Code:
    program New;

    procedure lalalalala;
    begin
    clickmouse(x,y);
    somethingelse;
    end;

    begin
    repeat
    lalalalalala; <-------------- Put main code like functions and procedures here.
    until(false);
    end.

  7. #7
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ape View Post
    Do this....
    SCAR Code:
    program New;

    procedure lalalalala;
    begin
    clickmouse(x,y);
    somethingelse;
    end;

    begin
    repeat
    lalalalalala; <-------------- Put main code like functions and procedures here.
    until(false);
    end.
    Its not really such a good idea to have an indefinite loop... for me the shortcuts dont work and some scripts move the mouse so much you cannot stop it...

  8. #8
    Join Date
    Apr 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You can stop the script with ctrl + alt + S
    Pause it with Ctrl + alt + a
    and run it with Ctrl + alt + r
    usually stopping it isn't an issue with hot keys unless you got a bunch of SCARs open.

  9. #9
    Join Date
    Mar 2008
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ape View Post
    You can stop the script with ctrl + alt + S
    Pause it with Ctrl + alt + a
    and run it with Ctrl + alt + r
    usually stopping it isn't an issue with hot keys unless you got a bunch of SCARs open.
    you are supposed to be able to stop it that way, but it never works for me =/ but thats beside the point... indefinite loops arent good to use, i suppose if you wanna do an indefinite loop thats your decision but i wouldnt advise it...

  10. #10
    Join Date
    Apr 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Honestly I don't care if it's a bad habit to get into, i just needed it to do what I wanted.

    Thanks everyone for help.

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

    Default

    Try this:
    SCAR Code:
    Repeat
    i:=1+1;
    PickWheat;
    Until(i > HowManyWheatToPick);

    Or try reading one of my Tutorials:
    http://www.srl-forums.com/forum/make...-t31587p2.html
    http://www.villavu.com/forum/showthread.php?t=28811

    Hope I Helped

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Very basic question
    By groog in forum OSR Help
    Replies: 1
    Last Post: 01-19-2009, 04:42 PM
  2. Loop
    By Ethan1221 in forum OSR Help
    Replies: 16
    Last Post: 12-22-2008, 05:31 PM
  3. Visual Basic Winsock, Infinite Loop Help
    By Miitchyy in forum C#/Visual Basic Help and Tutorials
    Replies: 4
    Last Post: 04-10-2008, 07:06 AM
  4. Loop help?
    By Becks in forum OSR Help
    Replies: 3
    Last Post: 10-23-2007, 10:32 AM
  5. Help with loop
    By skullbr00d in forum OSR Help
    Replies: 0
    Last Post: 05-29-2007, 09:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •