Variable error coming up, also a question on stats

Hello, all.

I'm sure someone somewhere has asked my questions before, but with over 430 pages in the support forum, I'm not sure I'll ever find it. So I hope you don't mind if I make a new post.

For my game I am trying to make a timing system for Morning, Afternoon, Evening, and Night. I've made one variable called, Time of Day. Depending on what number this variable is set to, 1=morning, 2=afternoon, ect. I have the system set to display a text box with what day, and what time of day for whenever this will change, which is based on certain events that I have set to increase the variable, or reset it back to 1 should it get higher than 4. I have also set via a Common event, that is called by individual events, so that the variable with state a certain script when it equals 1, 2, 3, or 4 so it should become called Morning, Afternoon, Evening, or Night in the displayed text block.

My issue though is, after I've started the game and get through the main intro, the first time I call the event to change the time to Morning for the first time, it says "Morning is undefined," and the game crashes. What does this mean? Hope I've explained this clearly.

An additional question. I want to have different stats for each NPC that the PC can effect for each NPC. I thought at first I could use the main stats of the game and just rename them what I want, but, I don't know how to set each stat to a specific number, and then increase or decrease those numbers by a certain amount at a certain time. I want each stat to start at 1, and have 100 max. I want so that at certain times, depending on the character's actions, these will either increase, or decrease, based primarily on two of the stats numbers. For instance. If the character does something to increase stat 3, then the formulae for that would look something like "stat1 - stat2 = X (Then, if X is between A and B then amount stat3 will increase = 1. If X is between B and C, then Stat3's will increase by 2, and so on.")

Thank you for the help!
Dankbarer
That means that variable one isn't set to anything.

To get a day/night system that works, you need one parallel process common event. That acts like a clock, going through your day/night cycle. You'd use other events to call and reference certain variables at certain times like if variable 3 is your hours variable, then you have a set of conditions that would tint the screen, at different times.
I recommend watching this video tutorial and then this one for tinted screens.
#1 - Put Morning in quotes. It thinks you're referring to a variable with that name.

#2 - look around for a self-variables plugin, which allows you to give events self-variables similar to self-switches. I think Yanfly has one. Or if there are only a few and you want the stats to be exactly the same list that actors have, you could set up "dummy" actors for each of them and use the event commands to change their values. Personally I'd go with self-variables.
Zarsla and Shaz,

Thanks for the help! The crash has left thankfully and things seem to be working ok. I'll look into the self variables and see if that will work for me as well, thanks for the suggestions!

I am having an issue now though where the common event I made to advance time will work once, but when I try to use it again, it isn't bringing up the windows. Any ideas as to why?
@Dankbarer
Unfortunately our magic crystals are currently malfunctioning, so we can't see into your computer how your common event works ;-)

please give us a screenshot of the common event and we can start looking for the problem ;-)
You really should get those checked, they could be incredibly useful for people like me who mock people who don't post pictures of things and then go and do it themselves...But ok! Threaded together the screen shots of the common event to make it one image! Hope this helps.
You mixed up variable types - variables can be used to store strings/names, but as soon as you do that you can't use them for mathematical operations again until you set them back to a number.

You started using var 4 for counting the time of the day, and that works the first time because it is intended to be used that way by default.
But in the end of your event, you overwrite the stored number with the name for that time - ever tried calculating "timename xy" + 1?
You can't calculate with a name, and on second call that var 4 has become a name variable and can no longer be counted or processed with mathematical commands.

You need to store the name in a different variable for that to work
Ok, I understand what you're saying as to why it's not working. But, I'm afraid I don't understand how you're suggesting to fix it. I'm afraid I'm a bit of a newbie when it comes to this sort of thing. How would I store the name somewhere else? I have not tried calculating "timename xy" + 1, I'm really sure how to do that lol.

Thank you!
I have not tried calculating "timename xy" + 1,
yes, you did - in the very first command of this common event on its second call (which is why you get errors on calling it a second time).

At the end of the first time the event is processed, you have the command
Control variable #004 time of day = "Morning".

after that, in the second call of the event the very first command is cpmtrol variable #004 time of day +=1, that means "add one to the content of the variable number 4". But that content of the variable is now "Morning", so you now try to calculate "Morning" + 1 instead of the 1+1 that you should calculate.

you need to use a different variable for the name, like control variable #999 Name of time of day = "Morning", you cannot use the same variable that you're counting with for name storage.
yes, you did - in the very first command of this common event on its second call (which is why you get errors on calling it a second time).

At the end of the first time the event is processed, you have the command
Control variable #004 time of day = "Morning".

after that, in the second call of the event the very first command is cpmtrol variable #004 time of day +=1, that means "add one to the content of the variable number 4". But that content of the variable is now "Morning", so you now try to calculate "Morning" + 1 instead of the 1+1 that you should calculate.

you need to use a different variable for the name, like control variable #999 Name of time of day = "Morning", you cannot use the same variable that you're counting with for name storage.

I see, ok, sorry I misunderstood there.

So, the solution that immediately comes to mind is, I need to make a variable for each time of day, label them as Morning, Afternoon, Evening, and Night. Then create a conditional branch so that if Time of Day variable equals 1 then it will display Variable Morning, if it equals 2 then call the next corresponding variable, and so on and so forth. Unless there is a cleaner way to do that? I think I can at least visualize it this way.

Thanks for being patient with me on this.
I need to make a variable for each time of day, label them as Morning, Afternoon, Evening, and Night.
That is needlessly complex, you almost had it correct - you just need to change the variable 4 to a different variable in a total of five lines.
Four lines where you write control variable #999 Name of time of day = "Morning"
and the fifth place is the show text, where you use \V[999] instead of the current \V[4]

You can use any other variable than 999 of course, the only condition is that it MUST NOT be a variable that you use anywhere else.
Ok, so after getting home from work and trying to wrap my brain addled head around this, (I work in Customer Service and sometimes feel people's stupidity rubs off on me.) I think I was able to translate your advice into how to fix the event. How's this look?
it will work correctly.

For better readility you might want to disable the else branches on the conditionaly in the lower two sections however.
In a series of equal.checks there is no need for elses, because the other numbers can't be selected anyway. (elses are more for "bigger than" where you don't have a direct conection to a number)
Awesome, thank you very much for your help. I really appreciate it!

Original thread: https://forums.rpgmakerweb.com/threads/variable-error-coming-up-also-a-question-on-stats.81125/