This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Knovox's profile picture

Countdown timer not working?

Started by Knovox, 05 May 2017 - 09:39 PM
Knovox #1
Posted 05 May 2017 - 11:39 PM
Hello,

I was making a countdown timer for a game I am making. I have made countdown timers before in Java as well as inside ComputerCraft. However, there is something weird that I just cannot pin-point for the life of me.

I am making two variables: mins and secs. Mins is mins = timerMinutes/60, and seconds is secs = timerMinutes%60. I believe that is correct.

However, the weird thing is that timerMInutes/60 is spitting out a bunch of numbers like so -> http://imgur.com/a/3grO7

I am pretty experienced with CC, but I still don't know everything. I am not sure if there is something I am missing here, but I just remember doing the same type of method to make a timer in Java. I am sure there is an easy enough solution to this.

Any help appreciated, thank you!
Lyqyd #2
Posted 06 May 2017 - 12:04 AM
Well, that's the actual result of the division operation. You probably want to math.floor() the result of the division, and use that number.
Knovox #3
Posted 06 May 2017 - 11:20 PM
Well, that's the actual result of the division operation. You probably want to math.floor() the result of the division, and use that number.

Thank you! Like I said I knew there was probably something I was missing or something else I could do. I will give it a try!