Hi, I was wondering if anyone know how to input milliseconds in the timer? So it look like this: 03:00:00 (3 minutes)
(REQUEST) Timer modification
Script RequestsEasy enough, give me a minute...
Here ya go!
On a side note, only if you're interested in knowing... its not really too important, but it doesn't hurt to learn something.
...I thought that was kinda interesting and you might like to know, because I didn't realise that until now either ;)
Here ya go!
Sprite_Timer+
Spoiler
- #==============================================================================
- # ** Sprite_Timer
- #------------------------------------------------------------------------------
- # This sprite is used to display the timer.It observes the $game_system
- # class and automatically changes sprite conditions.
- #==============================================================================
- class Sprite_Timer < Sprite
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super
- Graphics.frame_rate = 0.01
- self.bitmap = Bitmap.new(132, 48)
- self.bitmap.font.name = "Arial"
- self.bitmap.font.size = 32
- self.x = 640 - self.bitmap.width
- self.y = 0
- self.z = 500
- update
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- self.visible = $game_system.timer_working
- if $game_system.timer.to_f / 40.0 != @total_sec
- self.bitmap.clear
- @total_sec = $game_system.timer.to_f / 40.0
- min = @total_sec / 60
- sec = @total_sec % 60
- mil = (@total_sec.to_f * 60) % 60
- text = sprintf("%02d:%02d:%02d", min, sec, mil)
- self.bitmap.font.color.set(255, 255, 255)
- self.bitmap.draw_text(self.bitmap.rect, text, 1)
- end
- end
- end
Expand to see the code.
On a side note, only if you're interested in knowing... its not really too important, but it doesn't hurt to learn something.
Interesting find about changing Graphics.frame_rate
Spoiler
I learned something new upon testing your request. I wanted to actually test the accuracy of the milliseconds, so I changed Graphics.frame_rate from 40 to 20 to 10 to 1 to 0.1, etc you get the idea, just so I could see the actual milliseconds counting down. Keep in mind, I tested the timer set at 1:00 at all times...
Well, as I started changing Graphics.frame_rate, I noticed the lower it was the higher the timer was and visa versa. For instance, Graphics.frame_rate = 20 would make the timer 2:00 instead of 1:00, and Graphics.frame_rate = 80 would make the timer 0:30... that isn't right! Remember how I said I set the timer at 1:00?
RMXP's frame_rate is supposed to always be 40
RMVX's frame_rate is supposed to always be 60
Many anti-lag scripts I've seen change Graphics.frame_rate to try and speed up the game when it is lagging, which is okay and works sometimes but will affect the Timer and possibly Window_Playtime's time. The solution, you can do a CTRL+SHIFT+F and replace anything that references Graphics.frame_rate with 40 (or 60 for VX), and you won't have to worry about Graphics.frame_rate affecting timed-things.
Well, as I started changing Graphics.frame_rate, I noticed the lower it was the higher the timer was and visa versa. For instance, Graphics.frame_rate = 20 would make the timer 2:00 instead of 1:00, and Graphics.frame_rate = 80 would make the timer 0:30... that isn't right! Remember how I said I set the timer at 1:00?
RMXP's frame_rate is supposed to always be 40
RMVX's frame_rate is supposed to always be 60
Many anti-lag scripts I've seen change Graphics.frame_rate to try and speed up the game when it is lagging, which is okay and works sometimes but will affect the Timer and possibly Window_Playtime's time. The solution, you can do a CTRL+SHIFT+F and replace anything that references Graphics.frame_rate with 40 (or 60 for VX), and you won't have to worry about Graphics.frame_rate affecting timed-things.
...I thought that was kinda interesting and you might like to know, because I didn't realise that until now either ;)
Thanks alot man :D I've always hated that the timer doesn't show ms, it doesn't give you the feeling that you must hurry. But know it looks so much better.
Original thread: https://www.hbgames.org/forums/viewtopic.php?t=65435