Results 1 to 4 of 4

Thread: Simple but a lil ot much for me x.x

  1. #1
    Join Date
    Aug 2007
    Posts
    328
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Simple but a lil ot much for me x.x

    I wanted a integer to count such as:
    SCAR Code:
    Slept := Slept + 1;

    now i want it to count up to something like
    SCAR Code:
    Slept > (3 + (random(2))
    Once it counts the said time i want it restart counting but how? O_O

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

    Default

    SCAR Code:
    if (Slept > 3 + Random(2)) then // If counter has passed the target
    begin
      Slept := 0; // Reset the counter
      blah; // Do what else you need to do here that should be done as well
    end;

    Depending on how often you test the counter, the Random(2) will be pretty useless as multiple times per loop would most likely result in it returning 0 at least once. If it's only 1 test per loop, then it should be fine (test referring to have the little code above that checks if it's larger then resets it if it is).
    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.

  3. #3
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    1,124
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Slept := original value;

    is this what you are looking for?

  4. #4
    Join Date
    Aug 2007
    Posts
    328
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    SCAR Code:
    if (Slept > 3 + Random(2)) then // If counter has passed the target
    begin
      Slept := 0; // Reset the counter
      blah; // Do what else you need to do here that should be done as well
    end;

    Depending on how often you test the counter, the Random(2) will be pretty useless as multiple times per loop would most likely result in it returning 0 at least once. If it's only 1 test per loop, then it should be fine (test referring to have the little code above that checks if it's larger then resets it if it is).
    Oh my thanks XD never knew it ws that simple X3

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
  •