(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
219
Reaction score
201
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
387
Reaction score
539
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,410
Reaction score
2,132
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

one of the coolest things I've learned from the forums is the ability to give yourself a hitbox. I have a move you can do on the fields. shoulder tackle. thanks to the forums, that tackle triggers self A switches on some events. NPC's and the environment now react to the tackle. awesome.
I really liked how this one turned out! :kaopride:
WYqMPf6.png

Character (Yes, this is a character): Nibiru the Primal Being from Yugioh.
Dragon Quest style enemy selection plugin work in progress:

Quest_Targeting.png

It's a simple targeting system from the NES era. Select an enemy group; single-target skills will target the first enemy in that group.

Quest-Targeting-Animated.gif
Somehow that granny topic got me... maybe I can come up with some more thematic stuff :3
Going live for tonight's stream! Kytt isn't feeling 100% tonight so the wifestream will be tomorrow and I'll be playing Final Fantasy XIV for this one instead. Twitch

Forum statistics

Threads
121,933
Messages
1,145,263
Members
160,207
Latest member
RiceKun
Top