A question about variables?

Hey guys, I was wondering if there was a way for an event in RPG Maker VX Ace to check if a variable has changed?

In the case of the RPG I am currently making, I have set up a 'calender' in which at the end of each day, the date changes over.

I was wondering if there is a way to get an event to check if a particular variable has changed, so that it can tell if a night has passed.

If I were to express it in pseudo code, it would (basically) be something like this;

">If var_date has changed then

  >*Act upon it*

>Else

  >*Do nothing

>End if"

Any help would be greatly appreciated!

Thanks everyone!
At the start of each day, set a variable to hold the value of the day and then have it check against said variable:

if $game_variable[n] != $game_variable[x] (set this to the value that is being checked against)

 #code

Perhaps I might not have helped in the right way, or maybe I have.  Let me know if this is what you were looking for.
You need two variables. One that is the variable you want its value changed, and the other is just a random one you're going to be using. When you want to start checking if the value has changed, you will set the original variable to the random one. This is a one-time thing only. Turn on a switch, and create a parallel process common event with this switch. Inside, you will use a conditional branch that checks if those two variables are equal to each other. If true, it means the value has changed. If not, it has stayed the same.
Thank you so much for your help guys!

DjDarkX, I tried your way "if $game_variable[n] != $game_variable[x]" but it didn't seem to work, I made a conditional branch for "$game_variables[2] == $game_variables[41] + 1" where $game_variable[2] was the date and $game_variable[41] was a variable set to the value of the date at the time of the 'crops' creation. It works great in the respect that when the date changes, the plant grows, but if there is more than one plant it resets the $game_variables[42] to the current date, which in turn means that if two crops are planted, one a day after the other, the first planted will take a day longer to grow, as the VAR has been reset, meaning they both mature at the same time!

To give context to my problem, I'm currently trying to make a 'farm' type event, in which the player plants a crop, and at the end of each day,

it advances a stage in its growth. My day is divided into 7 segments, Early Morning, Morning, Midday, Afternoon, Evening,

Night, and a period of time which is purely for coding purposes (when it reaches this time of day, it automatically skips

to Early Morning of the next day). I was wondering how I would go about making it so that at that seventh segment of the day,

my 'crop' event, would advance a stage in it's growth, as this would allow for the appearance of crops growing overnight.

 

And to Celianna, thanks for you help too! But I ran into the same problem above! It's so frustrating! XD

Thank you so much for all your help, I really appreciate this! 😀
Show us your event. Don't describe it in words - actually take a screenshot so we can see the exact commands you've used.


The logic is correct, so there must be something you've missed in the implementation. We need to see both where the variables are set, as well as where they're updated. Without seeing anything, my guess is that you're updating one of them at the wrong time, and they're always going to be equal.
Oh right, my bad. Here;

[IMG]http://s6.postimg.org/lx44xjv8h/Crop_Event_1.jpg[/IMG][IMG]http://s6.postimg.org/89y2pc15t/Crop_Event_2.jpg[/IMG]

[IMG]http://s6.postimg.org/xh8ypl49t/Crop_Event_3.jpg[/IMG]

[IMG]http://s6.postimg.org/cye2kiqch/Crop_Event_4.jpg[/IMG]

That's the four pages of the event (sorry if the size is a bit dodgy!)
Okay, and where do you change the date? And are you using a different variable for every 'plot'? You would need to.


I'm going to give you a better way to do all the above, btw, so you don't have to use parallel processes (lots of events doing this will make your game lag pretty badly).


Actually, on rethinking, the method I was going to use won't work.


Have you seen my Extended Game Timers script? Would let you set a timer to turn on the self switches, without relying on a variable OR the date (as long as the date changes consistently).
The date change? That's a common event structured as such;

[IMG]http://s6.postimg.org/pr26kg1y9/Date_change_Common_Event.jpg[/IMG]

A new variable for each crop? I kinda figured that but I hoped there'd be a way around it, (so that there could be an 'unlimited' number of crops or rather the player could make crops himself).

And a better way? Oh, I like the sound of that! (In case you haven't noticed by now I'm still very new to RPG Maker in any great depth).

Thank you so much for your help Shaz!
When your date changes back to 1, your crop events will stop working if you plant them within the last few days, because the date will never get that high.


Check out the script in my previous post. May be just what you need. You've just got to figure out how many seconds to wait for each day. Using that, you can get by without any switches or variables or any reference to the date switch (and the issue I just mentioned with setting date back to 1 will be avoided too).


Let me know if you want to try it and need help, and in that case, I'll need to know how many seconds would go by before the date changes.
Yeah, I tried using timers/second based growth, however the time in my game isn't dictated by the passing of time, it's in 7 increments per day, which are managed by variables. I don't know if you have ever played a Persona game? The time works exactly like that. Certain tasks you fulfill will advance the time to the next increment, say from morning to midday. The problem with using timers and other real-time based growth is that the player could wait for the required time withing the one time period, and 'infinite farm' for want of a better expression. 
With farming type games, you'll HAVE to create a new variable for each crop. Unless you find a script that allows you to use self variables.


Also ... why do you think it is cheating that the player has to wait a certain time for the crops to grow? You could have crops take several weeks for them to grow - and no one likes to wait that long.
It's not the waiting that the problem, it's the fact that within one period of time, say Morning on the 16th (for example), a person could plant an entire field of crops, and if they are real-time based, wait for them to grow, before harvesting them and replanting again, ALL on the morning of the 16th. 

Having said that, I see what you mean about variables Celianna, and I actually may try and find a script that allows for self variables (I tried looking for one before, but I think I was using the wrong terminology)
 

Anyway, thank you so much for all your help everyone, you have been extremely helpful! 

P.S, I am very much looking forward to your Rural Farm tiles Celianna, they look fantastic!!!
Then I think, if you want to stick with this method, you're going to just have to debug and see what all the variables are set to, to figure out why they're not working. F9 will let you look at the values of your switches and variables, so when you THINK something should be happening and it's not, you can see what they're actually set to.


I do think, since you're using == as your comparison, it will fail if you do go to a different map, let 2 days pass then come back again - because the page that's active will be looking for the date + 1 to be the variable, not the date + 2. Maybe changing the test to >= instead of == might fix that.
Ah I've fixed it! I took Celianna's advice and found a script for self variables, and it works like a charm!

Thank you so much for all your help everyone! You've all been fantastic!! 😀

I can now implement farming into my game! Hooray!!! 😀
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/a-question-about-variables.17871/