[SCRIPTING] [RMVX ACE]INVOKE WAIT FOR LESS THAN 1 FRAME?

Posts

Pages: 1
(quite technically, a printer is also a computer...)

Anyway, hi! I'm making a simple enemy hp bars script, and wanted to make the filling/emptying of the bars to be gradual instead of instant. So, I plopped in a while loop containing Graphics.wait(1). While it does work, it's rather slow. Too slow. I was wondering if there was any way to wait for less than 1 frame. Or if there was a better way to make the filling/emptying gradual besides this method I'm using (which is rather clunky), I'd love to hear that as well.

Here's that portion, in case you're interested.
def update_hp_bar
    return unless @hp_pval != @battler.hp
    p 'update hp'
    @hp_pval = @battler.hp
    hp_cur = @hp_bar.bitmap.width
    hp_hgt = KS_P_B::HP_H
    hp_rat = hp_cur / KS_P_B::HP_W
    while ((hp_rat * 100).to_i) != ((@battler.hp_rate * 100).to_i)
      @hp_bar.bitmap.clear
      if hp_rat > (0.5)
        hp_c = KS_P_B::COLOUR[:hpf]
      elsif hp_rat > (0.25)
        hp_c = KS_P_B::COLOUR[:hpm]
      else
        hp_c = KS_P_B::COLOUR[:hpl]
      end
      @hp_bar.bitmap.fill_rect(0, 0, hp_cur, hp_hgt, hp_c)
      h = hp_rat > @battler.hp_rate ? -1 : 1
      hp_rat = ((hp_rat * 100).to_i + h) / 100.0
      hp_cur = KS_P_B::HP_W * hp_rat
      Graphics.wait(1)
    end
  end


Thank you!
Make a variable called "Skip". Set skip to 0. Every time this script updates, increase Skip by 1. Now, only do "Graphics.wait(1)" every time Skip reaches a certain value. Then reset Skip to 0 at the same time.
That was fast...

Thanks Zachary! It works :)
I used Graphics.wait(1) if step % 4 == 0 though, so I don't have to reset.
Pages: 1