Stumped brain Or: Eventer's block. (this is a toughie)

So I have a day night cycle that goes through 24 hours, 60 minutes, and 60 seconds. Each one has its own variable assigned. . What I've ran into now is that I want to make buffs in the game run off of this time. This has posed a problem to me that I just can't wrap my head about how to accomplish. For everything hypothetical let's call this buff....Buff. And it will last 6 hours. I have absolutely no idea how to use my time system to be used for this buff timer. Everything I've ever done like this in the game I've always used the wait command and have it equal to a variable. This wouldn't work here though because even being somewhat imprecise and using the hour and the minute as variables, I'd still need to wait for 2 variables? How would that even work.

In addition, since these variables repeat, say I cast the buff at 23:00 and was just using hours for buff times. Since it flips back to 0 at 24 hours how could it be used to count? I'm just so lost on how to do this, I literally have 0 clue. Any ideas?
we can't really help unless you show us how you've done the time system.

but basically you need a continuous counter as the base, not one that resets. you can then make your time variables from that counter.
and the time check would be against the appropiate number of the continuous counter, not against your hours/days.
we can't really help unless you show us how you've done the time system.

but basically you need a continuous counter as the base, not one that resets. you can then make your time variables from that counter.
and the time check would be against the appropiate number of the continuous counter, not against your hours/days.
Sorry I should have clarified, I didn't event this day night cycle, it's just the day night cycle that comes with community lighting (it's 5 am here I've been up all night lol). In the plugin settings you can assign a variable to hours, minutes, and seconds. So these are the things that I have access to without being a javascript wizard. I know a bit of programming so I can hunt for some things in plugins at a very amateur level, but this code is just baffling to me, honestly it looks like a warlock wrote this in runes while speaking in tongues. Programmers scare me
You can't make something like this work with buffs without a new plugin, as far as I can think.

If you can put the trait you want in a state, it should just be a bit of math.

I haven't looked at the plugin you referenced to see what its script calls to retrieve the current time are, you'll have to paste those in where it says "the current hours" or "the current minutes".

Using Yanfly's Buffs & States Core:
Code:
<Custom Apply Effect>
user.currMins = the current minutes;
user.currHours = the current hours;
</Custom Apply Effect>

<Custom Turn End Effect>
let diff = the current hours > user.currHours ? the current hours - user.currHours : the current hours + 24 - user.currHours;

if (diff == 6 && the current minutes >= user.currMins || diff > 6)
    user.removeState(stateId);
</Custom Turn End Effect>
You can't make something like this work with buffs without a new plugin, as far as I can think.

If you can put the trait you want in a state, it should just be a bit of math.

I haven't looked at the plugin you referenced to see what its script calls to retrieve the current time are, you'll have to paste those in where it says "the current hours" or "the current minutes".

Using Yanfly's Buffs & States Core:
Code:
<Custom Apply Effect>
user.currMins = the current minutes;
user.currHours = the current hours;
</Custom Apply Effect>

<Custom Turn End Effect>
let diff = the current hours > user.currHours ? the current hours - user.currHours : the current hours + 24 - user.currHours;

if (diff == 6 && the current minutes >= user.currMins || diff > 6)
    user.removeState(stateId);
</Custom Turn End Effect>

Buffs in this sense would be a food buff that is out of combat, and battles are fought on the map, so it doesn't use the traditional battle system. For this to run it'd be a common event that is triggered by a switch being turned on when you eat the food. That common event then would check the time, use some sort of wait command, and then use a conditional branch until the timer was over, then remove the buff and turn the switch off. That's the basics, there would be more behind the scenes to insure you couldn't eat more than one food at a time etc, but that's not really relevant to this.

If this was just one number that was constantly increasing it'd be no problem I could do this in a heartbeat as long as I knew the tick rate of that number, it's just that I only have access to the hour, minute, and second variable that I can assign in the plugin settings. (without understanding what's going on in the plugin file itself)
now uh... im no scripter in ruby or anything but cant you turn 24 hours into 86400 seconds? so you can rely on one variable only, and then you can do a comparison operation to trigger the Buff at whatever interval, for example if you want the buff to be present from the beginning of the day till 6 am you can do greater than or equal 0 and less than or equal 21600 for example
Buffs in this sense would be a food buff that is out of combat, and battles are fought on the map, so it doesn't use the traditional battle system.
It can still use states, but if you say that's not how your game works, then it isn't.

If this was just one number that was constantly increasing it'd be no problem I could do this in a heartbeat as long as I knew the tick rate of that number, it's just that I only have access to the hour, minute, and second variable that I can assign in the plugin settings.
Then you use the exact same logic I just showed you for calculating the time elapsed, just with event commands.
now uh... im no scripter in ruby or anything but cant you turn 24 hours into 86400 seconds? so you can rely on one variable only, and then you can do a comparison operation to trigger the Buff at whatever interval, for example if you want the buff to be present from the beginning of the day till 6 am you can do greater than or equal 0 and less than or equal 21600 for example
Unfortunately the variable that controls seconds only goes 1-60
Unfortunately the variable that controls seconds only goes 1-60
awh... unfortunate, sorry
Unfortunately the variable that controls seconds only goes 1-60
You use a game variable.

When you do whatever starts your food buff, you set a variable equal to 0 and turn on a parallel common event.

The common event has a Wait for however long your in-game seconds are, then adds 1 to that game variable. If it's equal to 21600, remove the buff and turn the parallel event's switch back off.

You're responding to several functional suggestions like you haven't thought through or tried them at all.
You use a game variable.

When you do whatever starts your food buff, you set a variable equal to 0 and turn on a parallel common event.

The common event has a Wait for however long your in-game seconds are, then adds 1 to that game variable. If it's equal to 21600, remove the buff and turn the parallel event's switch back off.

You're responding to several functional suggestions like you haven't thought through or tried them at all.
Yeah, gonna go to bed lol. I'll try your suggestion with the buffs states core when I wake up, I think the lack of sleep is making me delusional.

Edit: Also reading the second of this part makes a lot of sense, that would work too.

Brain no work. ZZZzzzz

I've moved this thread to MV Support. Thank you.

General Discussion isn't meant for getting help with specific projects.
You can't make something like this work with buffs without a new plugin, as far as I can think.

If you can put the trait you want in a state, it should just be a bit of math.

I haven't looked at the plugin you referenced to see what its script calls to retrieve the current time are, you'll have to paste those in where it says "the current hours" or "the current minutes".

Using Yanfly's Buffs & States Core:
Code:
<Custom Apply Effect>
user.currMins = the current minutes;
user.currHours = the current hours;
</Custom Apply Effect>

<Custom Turn End Effect>
let diff = the current hours > user.currHours ? the current hours - user.currHours : the current hours + 24 - user.currHours;

if (diff == 6 && the current minutes >= user.currMins || diff > 6)
    user.removeState(stateid);
</Custom Turn End Effect>
Alright, I probably messed something up, but I tried using this, and it didn't work. Here's what I've done:

Step one, I make a food that calls a common event.
Spoiler
step1.jpg

This runs this common event:
Spoiler
step2.jpg
This first checks to see if the player has eaten, if so it tells them they are full and gives them back the food. If not it sets these 2 variables to the time variables used by the plugin. I do this so that when this is run they are set to the current time and can't be changed and we can use the plugin's variables to determine the current time.

I then add this to the buff that is called:

<Custom Apply Effect>
user.currMins = $gameVariables.value(62);
user.currHours = $gameVariables.value(61);
</Custom Apply Effect>

<Custom Turn End Effect>
let diff = $gameVariables.value(42) > user.currHours ? $gameVariables.value(42) - user.currHours : $gameVariables.value(42) + 24 - user.currHours;

if (diff == 6 && $gameVariables.value(41) >= user.currMins || diff > 6)
user.removeState(19);
</Custom Turn End Effect>

Spoiler
step3.jpg

At the end of this, if the buff is removed I'd add the switch hasEaten = off if I knew how to do that.

I then attempt to increase the ingame time by 7 and the buff doesn't go away.

Any clue why this wouldn't be working?
Just to confirm, since you've mentioned you're not using the traditional battle system - are there still turns? Can you confirm that things you put inside <Custom Turn End Effect> actually happen?
Just to confirm, since you've mentioned you're not using the traditional battle system - are there still turns? Can you confirm that things you put inside <Custom Turn End Effect> actually happen?
Turns don't exist, correct.
Can't you just work out what time the buff should wear off, wait for that time, and then turn the buff off again? Of course, that won't work if you skip time at some point, as you might skip over when it's meant to wear off. But otherwise, you can do something like:

3cPeGHi.png

Start the buff, and work out what time it will end. Here I'm assuming the buff will last 6 hours, so the minutes will be the same as the current minutes, and the hours will be the current hours, plus 6, then mod 24. And I'm turning on a parallel event to listen for the buff to turn off again.

eZaa7aL.png

And then when the current hours and current minutes equal the end time hours and end time minutes I calculated before, turn the buff off again.

Hm... I know normally you should have a wait in a parallel event so as not to slow things up just in case, but I guess I'd worry if you have time set to run fast it might not be checking at the exact time it hits. Though I guess this gives you a full in game minute to check, so it depends how fast you have time running. And if you're skipping over time for whatever reason (maybe you jump 8 hours forwards when the player rests) you might jump right over the end point; perhaps you'd need to make all buffs wear off if they go to sleep.

Original thread: https://forums.rpgmakerweb.com/threads/stumped-brain-or-eventers-block-this-is-a-toughie.170543/