acirnep

Veteran
Veteran
Joined
Mar 26, 2017
Messages
32
Reaction score
34
First Language
Italian,English
Primarily Uses
RMMV
The idea at the base of the game I'm working on is that there are a large number of events going on, and there is limited time available, so the player needs to choose which events they want to attend. So I need a time system.
However, for a variety of reasons, I do not want to use a time system based on real time, so I've been trying to set up a step-based time system.
I've based it off SRDude tutorial
and it works... until minute 59 of game time.
After that, it goes crazy.

This is how I set up the common event:

Screenshot 2017-08-12 14.52.12.png
9
and this is the event to make it start
Screenshot 2017-08-12 15.19.51.png

I have created a "watch" item following the example of the video, to check the time, and I have created several events in the map to check how many steps have been taken.
Up to 119 steps everything works as it is supposed to do: after 4 steps the time is 9:2, after 60 steps the time is 9:30
After step 120, everything goes crazy:
at 132 steps I get Day 26: the current time is 2:6
and if I check again, without taking any more steps, I get a different result: Day 268 the current time is 12:6
at 199 steps I get "Day 4246: the current time: is 0:39" and so on.
Btw, this does not happen before step 120, if I check the time at step 60 the risult is always 9.30.

If anyone has any idea what I've done wrong and/or is able to suggest a different solution I'll be really thankful :kaothx:
 

SwiftSign

Veteran
Veteran
Joined
Aug 5, 2015
Messages
184
Reaction score
45
First Language
English
Primarily Uses
RMMV
This is a lot of number for my poor little head. The only thing i can spot at the minute which I'm guessing would cause issues:

You use 'Game Variable Minutes = Steps'

But later you then -60 off Game Var Minutes - but the script will just reset minutes back to steps? Some vicious circle of timeeywimeyness. This could be causing glitches that just exponentially add on to your variables?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,968
Reaction score
14,820
First Language
English
Primarily Uses
RMVXA
It's because every time that parallel process runs, it recalculates minutes, and once the minutes goes over 60, it always adds one to the hour. So here is what it is doing:

Step 121: Hours are at 10 per the step 120 code
Set minutes to 60 (steps / 2, rounded down)
If minutes > 60 (which it is)
Add one to hours, so hours is now 11
Take 60 away from minutes, which makes it 0.

So at step 120 you are at 10:00, but at step 121 you are at 11:00 as you never reset the hours. So every time you take a step after step 120, you're also adding 1 to the hours. And once you hit step 240 it will get worse, it will be adding 2 to the hours.

What I'd advise instead is have the common event reset the days, hours and minutes each time it runs. You may need to use modular arithmetic to do it. For example:

Minutes = steps / 2 will tell you the total minutes passed, but
minutes = minutes mod 60 will then tell you how many minutes in the current hour you are. No need for the if statement to do that.

Similarly, hours = minutes / 60 will get you the total hours, and hours = hours mod 24 will get you how many hours have passed since the game started (and since you want to start on hour 9, you will probably need to add 9 to the final result).

Similar work will work for days, though you'll need to figure out how many minutes are in a day (1440), and use that.

So, overall, I'd change the entire common event to this:
control variables: temp = steps
control variables: temp = steps / 2 (use a temporary variable for this, as you will need this figure a few times)
control variables: minutes = temp
control variables: minutes = minutes mod 60. At this point your minutes should be correct.
control variables: hours = temp.
control variables: hours = temp / 60. This will get you the total hours that have passed.
control variables: hours = hours + 9. This is needed since you start at 9 am.
control variables: hours = hours mod 24. This will put you at the correct time of the day, in military time.
control variables: days = temp
control variables: days = days / 1440. This will get you the total days that have passed, if you start on day 0.
control variables: days = days + 1. This is needed since you start at day 1.

That should do it, unless you need months or something.
 

acirnep

Veteran
Veteran
Joined
Mar 26, 2017
Messages
32
Reaction score
34
First Language
Italian,English
Primarily Uses
RMMV
It's because every time that parallel process runs, it recalculates minutes, and once the minutes goes over 60, it always adds one to the hour.

Doh! That makes a lot of sense.
At first I was using mod but I can't remember anymore why I changed it (it wasn't working, and I'm pretty bad at note taking). I kept tweaking, when probably starting anew would have been more productive.
Thanks a lot, I am going to apply your advice.
 

Latest Threads

Latest Posts

Latest Profile Posts

Nightmare... Dreamt I posted a GFX resource post. With a work in progress glove icon that tinted to different colors. In the wrong forum. And I was in such a panic. I saw people writing posts in response, those "..." you see in discord and such. So I frantically tried to report my post as wrong forum, editing to say it's the wrong forum and that I "accidentally" posted it too early... Very odd dream to be honest...
The youngest photo of you is also the oldest photo of you.
People need to stop submitting their game to every single game jam without even reading the jam rules (╯°□°)╯︵ ┻━┻
Mom tested positive for COVID thanks to a single stupid coworker of hers not taking sh*t serious.
I'll prolly won't be on here for a while as we deal with this.
So before I inevitably start a new project to reorganize myself (I will make sure to save important info dw), I will make an external list of what I want in the final database.

Forum statistics

Threads
117,195
Messages
1,105,383
Members
153,332
Latest member
diorpancakes
Top