Having problems with making a "Day cycle" code

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
Gustavs14
Regular
Posts: 44
Joined: Mon Apr 03, 2017 2:06 pm
Contact:

Having problems with making a "Day cycle" code

#1 Post by Gustavs14 »

Hello.

I've looked up different day cycle codes already, but didn't really see any codes that were like mine, so here I am.

* WHAT I WANT TO ACHIEVE:

1) Showing which day it is (like day 1, day 67 etc). each new day start after completeing an "action" at 23:00

2) 24 hour clock, and each action that you do increases the time by 1 hour. for example, it's 16:00, and you "do the dishes", and it sets to 17:00.

3) showing what weekday it is (monday-friday).

How do I get all of this working together?

Thanks!

User avatar
saetan
Newbie
Posts: 16
Joined: Fri Jan 19, 2018 7:54 pm
Contact:

Re: Having problems with making a "Day cycle" code

#2 Post by saetan »

You could try ( hour +1 ) MODULO 24. In case someone runs into this not knowing the modulo operator, 24 MOD 24 == 0; 25 MOD 24 == 1; essentially A MOD B divides A by B and gives you the remainder. The operator symbol may be written as %.

Pseudocode:
Function act(action, currentHour, currentDay):
# do action here
currentHour = (currentHour +1) % 24
if currentHour == 0:
currentDay = currentDay +1

Then display currentHour and currentDay however you like.

verysunshine
Veteran
Posts: 339
Joined: Wed Sep 24, 2014 5:03 pm
Organization: Wild Rose Interactive
Contact:

Re: Having problems with making a "Day cycle" code

#3 Post by verysunshine »

Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.

Try searching the Cookbook. Someone else has already made a solution for this.

Build the basics first, then add all the fun bits.

Please check out my games on my itch.io page!

Post Reply

Who is online

Users browsing this forum: No registered users