Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Variable resets when transferring room to room :O

kirra

Member

Hi everyone, I'm having a problem with the variable system in RPGMaker VX.

I set a variable called 'Day Count' to implement a day system in the game I am currently working on. But every time the character transfers to a different room, the variable will reset itself to zero.

Does anyone have the same problem or any ideas to solve it?
Any help will be appreciated, thanks in advance.

Kirra
 
Ah, I think I know what your problem is.  Whenever you transfer to a different room, all parallel process common events start from the beginning.  When I made my day/night system, I needed to make a bunch of conditional branches...

Code:
@>Conditional Branch: Variable [0001: Time] = 0
   @>Wait 300 frames
   @>Control Variables: Variable [0001: Time] += 1
@>Conditional Branch: Variable [0001: Time] =1
   @>Wait 300 frames
   @>Control Variables: Variable [0001: Time] +=1
...
@>Conditional Branch: Variable [0001: Time] = 35
   @>Wait 300 frames
   @>Control Variables: Variable [0001: Time] == 0

If you're just doing a day count, then something like this might work:

Code:
@>Wait 300 frames
@>Control Variables: Variable [0001: Days] += 1

However, if you're making a seven day (or other number of days) system, then you'll need to do something like what I did.

Code:
@>Conditional Branch: Variable [0001: Day] = 0
   @>Wait 300 frames
   @>Control Variables: Variable [0001: Day] += 1
...
@>Conditional Branch: Variable [0001: Day] = 6
   @>Wait 300 frames
   @>Control Variables: Variable [0001: Day] ==0
 

kirra

Member

Thanks, it's working now. May I know what is the thing that solved the problem? Is it the 300 frames wait? Thanks a million by the way :)

Oh, I used the day count method you've provided :)
 
The difference is the conditional branches.  If you just have...

Code:
@>Control Variables: Variable [0001: Day] == 1
@>Wait 300 frames
@> Control Variables: Variable [0001: Day] == 2
...

then, every time you transfer, it starts back at the top, so it would set it at 1 and continue.  The conditional branches check where it was before you transferred and continues from that spot.  It's essentially a way to hold the place of the parallel event.
 
Guardian, can't you simplify part of it down to:

Code:
  @>Wait 300 frames
@>Conditional Branch: Variable [0001: Time] < 35
  @>Control Variables: Variable [0001: Time] += 1
 : Else
  @>Control Variables: Variable [0001: Time] = 0

And same with the 7-day system,
Code:
@>Wait: 300 frames
@>Conditional Branch: Variable [0001: Day] < 7
  @>Control Variables: Variable [0001: Day] += 1
 : Else
  @>Control Variables: Variable [0001: Day] = 0
 
Yeah, that would work just as well.  I used the numerous conditional branches because I had to tint the screen based on the variable.  I sometimes have trouble simplifying once I have something that works.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top