MOGHunter's Time System: Increasing a Variable Value by 1 and Only 1

As the title said, I have not figured a way to increase a variable value by 1 and only 1 in a specific in-game hour.

What I Want:
The concept is a farming game where the player can choose to not sleep and doing all-nighters as many as they want... until the debuff/passive state makes them a zombie farmer or some sort. While doing all-nighter the player will accumulate fatigue points. If they accumulate enough, at 6 AM in-game time morning a variable will be increased by one. A state then will be applied based on the value of that variable.

The Problem I Got:
The Variable's value increased too many, the player straight up become zombie farmer after one nighter.

What I Did:
I made three parallel Common Events:
1. Counting fatigue points if the player does an all-nighter.
2. Enabling a switch for 6 AM check at 5 AM.
3. Increase a variable and determine which state/passive will be applied to the player at 6 AM,
then disable the check switch. Screen capture included.
Spoiler: Common Event
Fatigue.jpg

Adding and removing the plugin command still didn't give me the desired result. Moving switch-off below the "enable_time" didn't work too.

Plugins Used in This Project:
- Yanfly Core
- DKTools
- DKTools Localization
- Yanfly Auto Passive States
- Yanfly Passive Cases
- MOG Actor HUD
- MOG Time System
- MOG Time System HUD
- Ventiqu Single Actor
A few things~
  1. The script condition is incorrect: = is used to assign values, use == or === for comparison. Technical details can be found here: Comparison Operators (MDN). Try this script condition instead:
    JavaScript:
    !$gameActors.actor(1).isStateAffected($gameVariables.value(5) + 3)
    The ! is the NOT operator, it converts true to false and false to true. The statement itself means:
    Is actor 1 not affected by the state with ID equal to (3 plus the value of variable 5)?
    There's no need for a comparison, since isStateAffected already returns a true/false value. 😤

  2. Parallel events will trigger repeatedly while active (generally once per frame). This means that while the event is active, hour = 6, and fatiguePointAccumulate > 299, then fatigueState gets +1 per frame. But at that stage, the event only turns off if that scripted branch condition is met! 👋

  3. Since this event is Parallel, turning off its switch will immediately disable it, ending the event at the current command. This means that the actor refresh Script command and the enable_time Plugin Command immediately after it will never run. 😅
If the switch is getting turned on at hour 5 (why not hour 6?), maybe try rearranging your event to something like this:
Spoiler: Suggested event structure
Code:
◆If:hour = 6
  ◆If:fatiguePointAccumulate > 299
    ◆Plugin Command:disable_time
    ◆Control Variables:#0005 fatigueState += 1
    ◆If:Script:!$gameActors.actor(1).isStateAffected($gameVariables.value(5) + 3)
      ◆Script:$gameActors.actor(1).refresh();
      ◆Plugin Command:enable_time
      ◆
    :End
    ◆
  :End
  ◆Comment:Do once~
  ◆Control Switches:#0021 refreshActor = OFF
  ◆
:End
😮‍💨
Ah... so the problem is my flawed logic. The suggested event structure works just like what I want. Thanks!

I set one parallel common event to enable check switches an hour before the process common events (Fatigue Check, Crop's Water Level Reset, Foraging Items Respawn, etc).

Code:
◆If:hour = 5
  ◆Comment: Refresh Actor at 6
  ◆Control Switches : #0021 refreshActor = ON
  ◆
 :End
◆If:hour = 5
  ◆Comment: Reset crops' water level at 6
  ◆Control Switches : #0022 waterReset = ON
  ◆
 :End
◆If:hour = 3
  ◆Comment: Reset foraging items at 4
  ◆Control Switches : #0023 forageReset = ON
  ◆
 :End

I do this because I'm afraid the switches will always be "on" if I enable them at the same hour the process common events executed. Is my logic on this also flawed?
Hello, glad your problem was solved! Can you put a picture of how you put the "If: Hour = 5" in event command lines (a picture of the event itself with the time-checking conditional)? Been having trouble with this part for a long while. Thank you!
@Annwfn you mean like this?
Spoiler: MasterSwitch Common Event
Master-Switch.jpg

I customized the MOG_TimeSystem's parameters to suit my project. I check the variable where the plugin store the "Hour Variable ID" (In my case, variable 1 that I labeled "hour").

MOGH-Time-Var.jpg
Wait, you're using MOG's timer and you use variables to check on the timer? I used to do this, but variable incrementation didn't seem to match it (incrementation of the variables seems to be faster through Common Events, almost 50% faster than through Parallel Event). How exactly does one set this up?

<> I created a personal "timer" that functioned by incrementing a variable alongside Yanfly's timer system, in an attempt to match Yanfly's timer. The timer I created was based on Event Timer Countup script. put by increase by 1 second every 12 frames. My "timer" variables also incremented every 12 frames. My variables were always faster O.O
Well, MOG already set a variable parameter to store the game hour and there's no difference there.

For Yanfly's Timer, personally, rather than storing them as a variable I prefer to check "what is the current second now". For example, I have another project where I use Yanfly's Timer as an in-game clock. To change the screen tint in that project I made this parallel common event:

Spoiler: Check Yanfly's Timer to Change Screen Tint
tinter.jpg

I set the variable 1 (timetint) to store the timer's second. I switched to MOGHunter Time System because I haven't managed to make the Yanfly's Timer run/count twice as fast.
I set one parallel common event to enable check switches an hour before the process common events (Fatigue Check, Crop's Water Level Reset, Foraging Items Respawn, etc).
Oh I see, it's just a different Parallel event. I'm not familiar with Mog's plugin, I thought maybe it had a special auto-switch feature or something. 😴

Note that when it comes to events, RMMV is technically single-threaded: it processes each event interpreter in sequence. This means that in terms of CPU/RAM usage, one Parallel event is actually very slightly better than multiple Parallel events. 😅

As such, you might want to consider having one Parallel event to handle everything. You could still have the separate processes in their own events, though, e.g.
Code:
◆Comment:This common event has Trigger: Parallel.
:       :It calls other common events with Trigger: None.
:       :Just to keep things nice and organised!
◆Common Event:Update Fatigue
◆Common Event:Update Forage
◆Common Event:Update Weather/Tint
◆Comment:Run 60/12 = 5 times per second...
◆Wait:12 frames
Note I've also added a Wait command at the end here, since I'm assuming you don't need this to run every single frame~
I have seen the Variable for hour, thank you for reminding me of its existence. I was using the Scripts to check for time ($gameTime.minutes() and the one for seconds and hours, however, they seem to disregard the timer). I need to address the minutes issue, see how I can solve that. Once done, I have dealt with one of the main pain points of my game.
@caethyril Thank you for the input and suggestion!
The problem for my project is cleared, for now.

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/moghunters-time-system-increasing-a-variable-value-by-1-and-only-1.117823/