(MV) Having an event keep track of Variable changes?

AnchyMorgan

Villager
Member
Joined
Feb 27, 2014
Messages
11
Reaction score
4
First Language
English
Primarily Uses
So I am trying to put together a farming system for my game, and I was wondering if there was a way to have an event keep track of changes to a variable and then run a command when a certain amount of changes has happened. For example, if Variable X changes 10 times, Event Y will run Command Z.
 

rpgLord69

Veteran
Veteran
Joined
Oct 23, 2021
Messages
226
Reaction score
209
First Language
Finnish
Primarily Uses
RMMZ
Well if you have some event that changes variable x, can't you just put control variable k +1 after every time you change x. And then have a parallel event Y where there's a conditional that if k = 10 -> do something and then set variable k = 0
 
  • Like
Reactions: Bex

AnchyMorgan

Villager
Member
Joined
Feb 27, 2014
Messages
11
Reaction score
4
First Language
English
Primarily Uses
Well if you have some event that changes variable x, can't you just put control variable k +1 after every time you change x. And then have a parallel event Y where there's a conditional that if k = 10 -> do something and then set variable k = 0
What I'm trying to do is have a global variable that affects all the crops, so having it reset each time a crop is ready to harvest isn't viable.
 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
111
Reaction score
91
First Language
English
Primarily Uses
RMMZ
Correct me if I'm wrong, but aren't these conditions on MV events? Edit: I use MZ so I don't know the tiny differences between the 2 versions.Screenshot 2022-01-25 114531.png
If they are you just make a new page and tick the 'Variable' box, and change the >= to 10. That'll make it so the page will only become activate when the variable is greater than or equal to 10.

Doesn't matter how that variable becomes 10. Once it does, any event that has that box ticked and changed to 10, will activate that page.
 
  • Like
Reactions: Bex

AnchyMorgan

Villager
Member
Joined
Feb 27, 2014
Messages
11
Reaction score
4
First Language
English
Primarily Uses
Correct me if I'm wrong, but aren't these conditions on MV events? Edit: I use MZ so I don't know the tiny differences between the 2 versions.View attachment 214086
If they are you just make a new page and tick the 'Variable' box, and change the >= to 10. That'll make it so the page will only become activate when the variable is greater than or equal to 10.

Doesn't matter how that variable becomes 10. Once it does, any event that has that box ticked and changed to 10, will activate that page.
The problem using that method is that without resetting the variable, all crops looking for a variable of 10 or higher will grow immediately.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
390
Reaction score
545
First Language
French, German
Primarily Uses
RMMZ
What I'm trying to do is have a global variable that affects all the crops, so having it reset each time a crop is ready to harvest isn't viable.

The problem using that method is that without resetting the variable, all crops looking for a variable of 10 or higher will grow immediately.

I'm not sure this will work the way you think it'll work.

From what I understand, you want to use only 1 variable to affect multiple crops separately. But how would that work?

You want each crop to react after the variable x changes 10 times, but how does the crop know when to start counting?

One way to solve this, is by having variable x start at 0 and periodically count up +1, then have each crop start "counting" by remembering the value of x. For example, the crop was harvested when x = 3, so the crop should reset when x = 13; another crop might have been harvested at a different time, and would therefore need to reset accordingly.

But here's the problem: if you want each crop to remember when they were harvested, you'll need a variable for each crop. You really can't get around that.

However, I think what you really want, is to avoid wasting an RPG Maker variable. Having to set aside a bunch of variables and naming every single one is a lot of work. Fortunately, you can avoid this by hacking Self Switches to make them behave like variables (for the crop only, of course).

I've done something similar here:

This was designed for a respawn system, but it should work the same way with crops. Also, this was designed to be time-based (parallel process common event that counts up every 1 second), but you can easily modify this to change its behavior.
 
  • Like
Reactions: Bex

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
111
Reaction score
91
First Language
English
Primarily Uses
RMMZ
Nolonar beat me to it. But yes, since events don't have personal variables, you have to use Self-Switches to do the counting.
 
  • Like
Reactions: Bex

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,468
Reaction score
2,159
First Language
Dutch
Primarily Uses
RMMV
Even if YEP_SelfVariables, there is also "multiple timers" that can take place.
Galv have a farm plugin that might work, but while there can be solutions,
you need to pick what works for you (free or paid), there is a another
self variable plugin by the name I forgot, but it can do it's job.
 

Latest Threads

Latest Posts

Latest Profile Posts

Having sweet eight hours dedicated ONLY to devving, so what do I do? :kaoswt:

SIX HOURS: Watch Resident Evil boss fight videos
TWO HOURS: Dev

All things come from God tho, sooo... procrastination = divine!:kaoluv: :biggrin: :biggrin:
I officially declare today "test play day." I'm going to waste the whole day playing video games, which isn't a shock to anybody, but hopefully today I'll play my own and figure out what still needs fixin's.
Empty Bottles and Health Extenders are now a thing.
Also the Sling-Shot does damage to enemies now, but not a lot and you won't get gold from killing them that way.
ScreenShot_5_26_2022_11_36_32.png
added a Panic gauge to battle. it fills up according to your actions. each character has a different passive that activates once the gauge is full. also once full, a countdown starts and after each action taken, the gauges decreases. with each character, the decrease is different.

Forum statistics

Threads
122,174
Messages
1,146,990
Members
160,431
Latest member
Thabet68
Top