Counting problem.

Posted By: MMike

Counting problem. - 02/12/08 15:33

Imagine i have a variable
var infinite increase ;

So, having a variablev that is showing a value from 0 to infinite number.. each time frame. lets call it infinite increase


and i want to make id = infinite increase
(That id will then be show on the screen- not very important)

but when the id is 50, i want it to be zero, and start counting from there according to the infinite increase .. so that id, will range from zero to 50, and each time it gets 50 , it starts from zero again.

i tryed to do somethink lke this:

var id = infinite increase ;

if(id=50){id-=50;} but this works for once only
if(id=100){id-=100;} but this works for once only
(...) i need a formula.

thanks.
Posted By: xXxGuitar511

Re: Counting problem. - 02/12/08 21:54

id = infinite_increase % 50;

...try this. not sure if it's what you meant?
Posted By: MMike

Re: Counting problem. - 02/12/08 22:04

each time my var gets >50 .. it will start coutting (increasing if infinite var increases...) , but not from 50..51..52,,. ++ but from zero again.. 0..1..2

% is a division part right?
Posted By: jonkuhl

Re: Counting problem. - 02/12/08 22:08

Code:
  
while(1) //I dunno if you'll need a condition in here
{
if(infinate_increase < 50)
{
infinate_increase += 1;
}
else
{
infinate_increase = 0;
}
wait(1);
}




The % method might also work as well.
Posted By: MMike

Re: Counting problem. - 02/13/08 15:00

Quote:

id = infinite_increase % 50;

...try this. not sure if it's what you meant?



Excellent... that really worked.. uff.

Well the manual is not very clear with that % operation..
© 2024 lite-C Forums