Results 1 to 7 of 7

Thread: How can I make a script repeat

  1. #1
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default How can I make a script repeat

    A set amount of times?

    Say, something like

    repeat
    { stuff }
    until(3) //the until would make it try 3 times to do stuff

    Any way?
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

  2. #2
    Join Date
    May 2012
    Location
    Texas
    Posts
    365
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try using the For.. To.. Do Loop
    Simba Code:
    For i:=0 to 3 Do
    Begin
      Stuff;
      MoreStuff;
    End;
    Mostly Inactive, School

  3. #3
    Join Date
    Jul 2009
    Location
    Australia
    Posts
    667
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    A basic way of doing this would be having an integer that simple increases every time:

    Simba Code:
    I := 0;
    repeat
      Stuff;
      I := I + 1
    until(I >= 3)

    ~Caotom

  4. #4
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Or alternatively:
    Simba Code:
    var I: Integer;

    I := 0;

    repeat
      //MyStuff;
      Inc(I);
    until(I >= 3);
    There used to be something meaningful here.

  5. #5
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Based Lord View Post
    Try using the For.. To.. Do Loop
    Simba Code:
    For i:=0 to 3 Do
    Begin
      Stuff;
      MoreStuff;
    End;
    And using that, I do not need an until, it only matters where I place the For.. To.. Do loop, correct?

    Quote Originally Posted by Frement View Post
    Or alternatively:
    Simba Code:
    var I: Integer;

    I := 0;

    repeat
      //MyStuff;
      Inc(I);
    until(I >= 3);
    That's a little more understandable to me. I'll try both ways. Thanks guys!
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

  6. #6
    Join Date
    May 2012
    Posts
    102
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Another loop you can use is While ... Do for example:
    Simba Code:
    var i: Integer;

    i := 0

    While (i < 5) Do
      begin
        DoStuff;
        IncEx(i, 1);
        writeln(IntToStr(i));  
      end;

  7. #7
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Wreck View Post
    Another loop you can use is While ... Do for example:
    Simba Code:
    var i: Integer;

    i := 0

    While (i < 5) Do
      begin
        DoStuff;
        IncEx(i, 1);
        writeln(IntToStr(i));  
      end;
    Wow, now I really hadn't thought of that. How ingenious! :P
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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
  •