"Turn based" clock system?

Hello!

I plan to have to box in the top right of my screen, the top half displaying the day, the bottom half displaying the time. Instead of the time ticking in real time or a slightly faster time, I only want it to tick when the player does action, specifically during an event when given a show choice command.

Based on the action the player takes, I want the time to tick in a 15, 30,45 minute or 1 hour interval. Once the time hits a certain hour, I want an event to start that drops everything and transfers the player to the next day, which also changes the day tick in the top corner. I also wanted a complete override button that simply allow the player to skip the day.

Is this possible? If so, could somone point me in the direction to properly set it up, what functions I could utilize to simulate this, or any helpful plugins? Sorry if this sounds too needy, or too much.
simple - because this basically isn't a true time system but only a step counter.

You'll use a variable to count the steps and the top right display shows the current number of those steps.
And instead of a compley time system automatically updating the variable, your events simply add to it whenever the player does something. And if the action is not by event but by skill, simply attach a common event to the skill that counts up.
I would do this by having a Common Event "Pass Time" and having any action that should cause time to pass call that Common Event. You can set a variable (before calling the Common Event) to indicate how much time should pass, or you could simply call the Event once for every 15 minutes that should pass. Inside the Common Event, change the Time variables (these are the variables that track hours and minutes) accordingly, and then erase the pictures you are using to show the current clock on the screen, and show new pictures based on the current time. The override button could call the Common Event enough times to end the day (or simply pass in a large number if using the set-a-variable method).

This is a bit vague, but it's the overall framework you'd use to set it up, and it will work. If there's a specific part you don't know how to do, feel free to Reply and I'll explain it in finer detail. If all of it seems like it's above what you know how to do, check out the links in @Andar's signature above to learn more about advanced uses for variables.
@MercyModx Sure. @Andar is right. Usually to control time you want at least a variable for minute, hour, and day. When a choice is selected, you have Control Variables Event Commands to make the minute variable increment by 15, 30, or 45, or you have the hour increment by 1. You decide which increment you want and place it where your next command executes. You can then call a common event for time resets. Make the common event in the database to do the following: check immediately if minute >60. If so, you want to assign minute mod 60 and then hour add 1. Next you check if hour > x where x is the amount of hours you want to let the player character be awake each day. If hour > x, then day add 1 and hour set 0 and minute set 0. When the common event is done, flow of game code returns to the line below the common event call. For the complete override, you just make it so when the player selects it, day add 1, hour set 0, and minute set 0. You could simplify this process to a single step variable, but then there's more math and the logic is less natural to look at. Since you're doing a click event VN, this should give you the direct time updates you want after each show choice. Also...you may want to mention in your posts it's for a VN project as people in the RPG Maker MV thread tend to think along the lines of standard RPG projects when offering solutions. Although, to be fair, you were quite verbose about seeking time updates on show choice decisions. Good job. Best! 😉
Thank you all so much! I'll let you know if I have trouble when I put it together when I get home!

EDIT: So, instead of doing it a sane way, I did it in a totally ludicrous way because I failed to understand how to do variables in ways other than simply being a switch. the way I came up with was this:

create a common event with the show picture command for the time box,

make two variables, minute and hour, hour having numbers 9-18, for 9 am to 6 pm, and minutes having 1, 15, 30, and 45, for 00, 15, 30, and 45 minutes. I can figure out changing AM to PM later. same with the day function.

so far, this works, I can change the hour and minute by event call, it just looks tedious in the common event page,
Dwn36.png

and this is how I would call in-event, first simply adding an event in the corner of the map to run the common event parallel to whenever I want to have a time change. when I don't, the box stays on screen, and I don't need the extra common event call.
Dwn45.png


later on ill just have to figure out more complex time changes, like adding two minute ticks together and getting a total of say, an hour and 10 or whatever. But for now, I think I have a strong "for dummies" method. Thanks again!!
@MercyModx Sure. @Andar is right. Usually to control time you want at least a variable for minute, hour, and day. When a choice is selected, you have Control Variables Event Commands to make the minute variable increment by 15, 30, or 45, or you have the hour increment by 1. You decide which increment you want and place it where your next command executes. You can then call a common event for time resets. Make the common event in the database to do the following: check immediately if minute >60. If so, you want to assign minute mod 60 and then hour add 1. Next you check if hour > x where x is the amount of hours you want to let the player character be awake each day. If hour > x, then day add 1 and hour set 0 and minute set 0. When the common event is done, flow of game code returns to the line below the common event call. For the complete override, you just make it so when the player selects it, day add 1, hour set 0, and minute set 0. You could simplify this process to a single step variable, but then there's more math and the logic is less natural to look at. Since you're doing a click event VN, this should give you the direct time updates you want after each show choice. Also...you may want to mention in your posts it's for a VN project as people in the RPG Maker MV thread tend to think along the lines of standard RPG projects when offering solutions. Although, to be fair, you were quite verbose about seeking time updates on show choice decisions. Good job. Best! 😉

I'm so sorry for double posting but I'm getting closer to my deadline, this is the last function to implement and I don't know what else to do...😩 What I thought I could do clearly didn't work, I found out I couldn't add to the hour variable properly, so I looked at other tutorials, played guide games, and spent all day thinking up solutions and trying them to no avail. since my "clock" system would only have 3 ticks, (4 if you include the hour going back to 00) I fear that using minute mod would force me to end up having to make pictures for times in between, such as adding 45 minutes to 30 minutes you would get an hour and 25 minutes, I would have to make a new graphic for that. it's also highly possible that you are explaining what I want perfectly and I'm just too dull to figure out how to do it. Could you maybe explain it a little finer? Again, so sorry!
@MercyModx Relax. Breathe. 45 + 30 = 75, which is 1 hour 15 minutes. You have everything you need in 15 minute increments. You're good. 🙂
@MercyModx Relax. Breathe. 45 + 30 = 75, which is 1 hour 15 minutes. You have everything you need in 15 minute increments. You're good. 🙂

oops, my bad 😅 im really bad when it comes to calculating time, anyway it works! yay! mostly. when the hour variable reaches 8, the maximum amount of hours, the if statement I have set won't run?
DwVWj.png


This would simply fade out the screen, and transfer the player to the day ending map, which houses a clock reset and day variable, however when the variable reaches 8 or above, the box stays on screen, the map doesn't change and the time basically freezes, and won't respond to either hour or minute changes? same goes with the override button I have set to end the day immediately.
@MercyModx Is this in a common event, or a map event? I can't see enough context around the lines of code you provided to deduce the problem you're having that's causing the issue you describe. Please provide a wider shot of the panel this code is in...and hang in there. 🙂
@mathmaster74 Sorry about that, it is in a common event, this is the whole sequence:
Spoiler: images
Dx9nf.png

Dx9e0.png

Dx9qB.png
@MercyModx Okay. I was thinking this from the snippet you gave me originally, but wanted to be sure. Everything looks good with the logic leading up to hour 8. This is a test, right? That's why you Erase Event at the end? That may be why nothing moves forward cyclically...because it can't start over if it's been erased. What I don't understand is why you never move to the other map before it ends and you get stuck. Anyway...if you just move to the new map and don't Erase Event you should, in theory, be fine. In other words...try deleting the Erase Event line. Give it a shot and let me know what comes of it. Best! 🙂
your logic structure is a bit convoluted and has holes where numbers get lost.

1) you should test minutes before you test hours, because if the numbers go above 60 the added hour will not be checked until the next cycle even if it already happened.

2) your idea of using the modulo operation is nice, but it will only work as long as it is guaranteed that you'll neither get more than one hour from minutes nor more than one day from hours. If there is any way how a player could get to two hours from minutes then the second hour would be lost (both 75 and 135 modulo 60 will result in 15 minutes rest, but in both cases only one hour gets added).
If you can guarantee that then it's OK.

3) why are you doing that as a parallel process? It would be much less lag if you make trigger = none and simply call it in every event that adds to hours or minutes

4) why do you have a wait between erase picture and the transfer event?
It has absolutely no purpose there and waits behave differently in parallel processes than they do in regular events

5) erase event will NEVER have an effect here - it can only erase map events, never common events and that means this parallel process will continue to run directly after the player is transfered

6) please remove the fadeout for testing.
you claim that the conditional branch never runs, but you have nothing to show that because the fadeout hides everything on screen.
My guess is that it does indeed run and you just assumed it would not run because the common event goes on in the next map - but that is not true, it's just that the erase doesn't function for common events. But see my point 3 for that.
@MercyModx Do you have a day variable set up yet? You say the minutes and hours all work fine throughout this test. If that's the case, you just need to move to the start of a new day. Hence, you just need to go back and set a day variable to add one to its value at the end of this process and reset the minutes to 0 and the hours to 0 (which you did with your hour %= 8 line) so the process can start fresh. The day variable will need to be initialized and that can't happen in this event or you will keep setting day = 1 when this event starts over. I initialize variables by making a map event set with a parallel trigger that runs on the first map in the game as soon as the character loads. The only code I put in that event is what each variable should start at and how I want each switch set in a new game. I end that event with the Erase Event command. If you do this and set a variable named day equal to 1, then use that same day variable in your event here as I described earlier, you will add the day component to the hour and minute formula that you have working. Let me know if you have questions or concerns. @Andar makes some good points as always. I think for right now because you said you are time crunched, go with what you have that works, and try to keep it moving forward. Don't stress. 🙂
your logic structure is a bit convoluted and has holes where numbers get lost.

1) you should test minutes before you test hours, because if the numbers go above 60 the added hour will not be checked until the next cycle even if it already happened.

2) your idea of using the modulo operation is nice, but it will only work as long as it is guaranteed that you'll neither get more than one hour from minutes nor more than one day from hours. If there is any way how a player could get to two hours from minutes then the second hour would be lost (both 75 and 135 modulo 60 will result in 15 minutes rest, but in both cases only one hour gets added).
If you can guarantee that then it's OK.

3) why are you doing that as a parallel process? It would be much less lag if you make trigger = none and simply call it in every event that adds to hours or minutes

@Andar
1. I made a new common event and switched the order, for some reason, now whenever minutes is set to 0 or more from the mod 60 command, the corresponding image doesn't show on screen anymore, it did before switching events. I even added \v[1] (the minute's value) to a text box where I'm testing time, while the value says 15, 30, 45 or whatever, as long as it is an overflow from the mod 60, it won't appear. however, if i add another amount, the correct image for the new value appears?

2. the game will only use 15-minute intervals, and won't ever add more than one whole hour to the minutes variable, so I shouldn't have a problem.

3. I was told that making it parallel would allow the player to continue clicking or moving around the screen, but your way works better, thanks!

Do you have a day variable set up yet? You say the minutes and hours all work fine throughout this test. If that's the case, you just need to move to the start of a new day. Hence, you just need to go back and set a day variable to add one to its value at the end of this process and reset the minutes to 0 and the hours to 0 (which you did with your hour %= 8 line) so the process can start fresh. The day variable will need to be initialized and that can't happen in this event or you will keep setting day = 1 when this event starts over. I initialize variables by making a map event set with a parallel trigger that runs on the first map in the game as soon as the character loads. The only code I put in that event is what each variable should start at and how I want each switch set in a new game. I end that event with the Erase Event command. If you do this and set a variable named day equal to 1, then use that same day variable in your event here as I described earlier, you will add the day component to the hour and minute formula that you have working.

So I added a day variable, it only ticks over when the hour is greater or equal to 8, however, when I set the hour to at least 8, the player transfer won't occur until i force another variable change, making the minutes or hour higher than what the reset sets it to on the next day. What should I do to stop that? this is what it looks like now.
DxcUV.png
the player transfer won't occur until i force another variable change, making the minutes or hour higher than what the reset sets it to on the next day. What should I do to stop that?

@MercyModx One possible solution would be this: Force that variable change so the transfer happens. Once the transfer is done, you're on the DAY END map and all you can do is finish the day before going to a new day start, right? Put an Event Command of Control Variables in the Click Event that takes you to the new day start and use it to reset the variable changed from earlier back to 0. Sound good? Keep me posted. 🙂
@MercyModx One possible solution would be this: Force that variable change so the transfer happens. Once the transfer is done, you're on the DAY END map and all you can do is finish the day before going to a new day start, right? Put an Event Command of Control Variables in the Click Event that takes you to the new day start and use it to reset the variable changed from earlier back to 0. Sound good? Keep me posted. 🙂

so this does and doesnt work, when i transfer to the day end map, the variables do reset, so thats good, however the override button seems to repeat? same with the hour variable reaching 8? the hour variable goes up, but the day doesnt change, the hour disappears and the testing event on the map just resets? selecting another choice THEN changes the map? this is the test event:
Dxf4T.png


also any thought on this?

I made a new common event and switched the order, for some reason, now whenever minutes is set to 0 or more from the mod 60 command, the corresponding image doesn't show on screen anymore, it did before switching events. I even added \v[1] (the minute's value) to a text box where I'm testing time, while the value says 15, 30, 45 or whatever, as long as it is an overflow from the mod 60, it won't appear. however, if i add another amount, the correct image for the new value appears?
@MercyModx in this screenshot your first line is a call to Common Event: test 2. Is that the time management event we just got out of?
Its the event I've been working on since Andar told me to switch minutes on top of hours, so i guess so?
Okay. Let's try a thing or two: 1) move that common event call to the end of the Contents. Check what happens. If fixed, stop here, you're good. Otherwise, 2) remove the common event call entirely. Check what happens. If fixed, you're good. If either of these gives improved results...keep the project in that status and update me.
Okay. Let's try a thing or two: 1) move that common event call to the end of the Contents. Check what happens. If fixed, stop here, you're good. Otherwise, 2) remove the common event call entirely. Check what happens. If fixed, you're good. If either of these gives improved results...keep the project in that status and update me.

the first option worked! Yay! Now it's just the mod 60 issue, thanks so much!

Original thread: https://forums.rpgmakerweb.com/threads/turn-based-clock-system.109284/