Help - Search - Members - Calendar
Full Version: Updating Variables every frame.
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
beam_chris1
I'm working on a script and I need to increase a variable every frame
I'm new to scripting and have no idea how to do this. any help is appreciated.
DUFUTA
QUOTE (beam_chris1 @ Jul 17 2011, 06:06 PM) *
I'm working on a script and I need to increase a variable every frame
I'm new to scripting and have no idea how to do this. any help is appreciated.



There's something in the Game_Interpreter which says @wait_count. Not sure how you access it though, as it's in an update for loop. But, I'd advise looking around in there some. You'll probably find it somewhere.

You could do this easier by simply eventing it.

Parallel Common Event when some switch is on

Var1 = x
wait 1 frame
Var1 += 1
beam_chris1
I tried eventing it but the parallel processes causes the abs script I'm using to glitch and the enemies don't disappear when they die. The script works fine normally and I double checked that I had set up the enemies correctly. I did find one solution to this issue by adding the erase event function to the loop in the parallel processes, but although the enemies now disappear the tile they died on becomes impassable. Again this only happens when I'm running a parallel processes. Is there a way I can set up Kylock's Time System to add 1 to a variable every In-game hour and not reset it at the end of the day?
Night5h4d3
RGSS2 stores it's frame count, you can do something like this:
CODE
@count_start = Graphics.frame_count
while @count_start < @limit
$game_variables[<insert variable number here>] =  Graphiccs.frame_count -  @count_start
end


@count_start gets the graphic's current frame (say 20)
@limit is how high you want it to go (say 10)
$game_variables[] is the variable you want to increment
so, every time you go through the while, the variable is being set to the difference of Graphics.frame_count - @count_start. after @count_start reaches 10 (10 frames later) it will stop incrementing said variable.


EDIT - to do it by hours, you'd do something like:
CODE
@count_start = Graphics.frame_count
while @count_start < @limit
$game_variables[<insert variable number here>] =  (((Graphiccs.frame_count -  @count_start)  /  Graphics.frame_rate) / 60 / 60).truncate
end
beam_chris1
I figured it out, thanks for the help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.