Say I want to add +20 to some variable, but I only want the effects to last for a few seconds or a couple of minutes, how can I set the effect to ware off in the script editor?
like this pseudo code:
def temp_fx
for 20 seconds do [my_variable_bonus = 20]
after that [my_variable_bonus = 0]
end
it appears things move in 30 frames per second but I'm not yet sure how to access those variables without directly accessing the game total play time. I'll try some different versions of if _ x -=1 and +=1 but I'm kind of lost as to the time mechanics of RPGmaker.
So I came up with this:
class Counting_Clock < Window_Base
def initialize
$counting_clock=0
while $counting_clock < 30
$counting_clock += 1
end
super(240, 160, 120, 120)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Times New Roman"
self.contents.font.size = 24
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(30, 25, 100, 32, $counting_clock.to_s)
end
end
And it pops up a window with the number 30, and does so instantaneously. I've done a print variant where you have to hit 'ok' for it to transition from 0 ..1.. 2, etc. But while normally does everything instantly. I'm trying to display a smooth number climb, but i'm not sure how time is portrayed in this code.
class Counting_Clock < Window_Base
def initialize
t = Time.now
q = t.sec
m = q + 5
$counting_clock=0
case q
when m
$counting_clock=30
super(240, 160, 120, 120)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
refresh
else
$counting_clock=0
super(240, 160, 120, 120)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
refresh
end
end # end initialize
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(30, 25, 100, 32, $counting_clock.to_s)
end
end # end class
unfortunately this displays only the else result, in this case, "0". It doesn't auto update and the window closes automatically after a few seconds.