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.
(MV) Having an event keep track of Variable changes?
RPG Maker MV SupportWell 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.
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.
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.
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.
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:
Skeletons who rise up after defeat every game hour.
I want to create opponents, let's say they are skeletons that crumble into bones after defeat, but every hour of the game time these bones are reassembled into a skeleton again. And to permanently kill them it is necessary to destroy the tombstone on the location, which causes their...
forums.rpgmakerweb.com
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.
Nolonar beat me to it. But yes, since events don't have personal variables, you have to use Self-Switches to do the counting.
In this case, I think you need to use Self Variables:
www.yanfly.moe
Self Switches & Variables (YEP) - Yanfly.moe Wiki
Hmm, that might work. I'll try it once I get money again.
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.
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.
Original thread: https://forums.rpgmakerweb.com/threads/mv-having-an-event-keep-track-of-variable-changes.144317/