Stop the clock at midnight

How do I…

Hello,

I have a game with multiple actions that people can choose from without any order. I am trying to link these actions to a digital clock where a specific amount time will pass depending on the action that player’s choose and all actions can be chosen only once. The game should stop when the clock hits midnight. What condition should I use?

For example,

  • The clock starts at 19:00 at the beginning of the game
  • 4 different actions are available:
    • Study
    • Watch a video
    • Read a book
    • Call your mom
  • If they choose study, it adds +2 hour to the current time. This doesn’t cause any problem at this stage because the time was 19:00 so it becomes 21:00
  • However, if the time was already 23:00 and the player chooses the Study action the time goes to 25:00 instead of stopping at midnight (24:00).

I am using two variables to track the time:

  • Hour
  • HourIncrement

I have “The variable Hour > 24 - Change the variable Hour: set to 24” event as a temporary solution, but it first shows 25 for a brief moment then goes to 24. I don’t want to see 25 at all

How do I...? App-Events

If it shows 25 first, then it could be the sequence. Make sure the value is changed before it’s displayed. Events are processed from top to bottom. If the value is changed after the text is displayed, then it won’t show 24 until the next frame.

You could change the line where the time is adjusted. If you use the expression min(#, #), it will choose the minimum number.

min(20,24) would return 20
min(28,24) would return 24

The order of the numbers isn’t important. It will always choose the smaller number.

There might be a different solution or issue. The user should probably be told upfront that at 23 hours that there’s not enough time to study for 2 hours. Either inform them there’s not enough time or only give them the option to study for 1 hour instead of 2 hours.

Aside from Keith suggest i wonder if what you want to achieve even make sense

Look
You want to study for 2 hours
After that 2 hours you gain something in return as i would assume
So why you would allow to study for 1 hour and split possible profit?

It is like you would be allowed to take down half of boss HP and get either full or half reward for it
NO you either bring him to 0 HP or you get nothing

And i would follow same logic which would be WAY easier for you to manage

Simply in every action you would just check if its enough time

For example
Time is less than 22:00
Study button is pressd

And here you do whatever in action if conditions are meet

If its above 22:00 you could simply display message
“To late for me to study, i should finish my other tasks and get to bed soon”

At least for me it would make a lot more sense

Fak i just read end of Keith post above and it is pretty much same thing

But you get the idea