Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Updating Variables every frame.
beam_chris1
post Jul 17 2011, 06:06 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 13
Type: Event Designer
RM Skill: Skilled




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.
Go to the top of the page
 
+Quote Post
   
DUFUTA
post Jul 19 2011, 11:00 AM
Post #2


Level 5
Group Icon

Group: Member
Posts: 60
Type: Musician
RM Skill: Intermediate




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
Go to the top of the page
 
+Quote Post
   
beam_chris1
post Jul 19 2011, 11:27 AM
Post #3


Level 1
Group Icon

Group: Member
Posts: 13
Type: Event Designer
RM Skill: Skilled




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?
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 19 2011, 11:32 AM
Post #4


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




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


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
beam_chris1
post Jul 19 2011, 12:36 PM
Post #5


Level 1
Group Icon

Group: Member
Posts: 13
Type: Event Designer
RM Skill: Skilled




I figured it out, thanks for the help.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 09:12 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker