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 » Mon Feb 12, 2018 12:16 pm

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 » Mon Feb 12, 2018 2:15 pm

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: 231
Joined: Wed Sep 24, 2014 5:03 pm
Projects: No Good Wife
Organization: Wild Rose Interactive
Contact:

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

#3 Post by verysunshine » Tue Feb 13, 2018 4:31 pm

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.

"Date for the romance. Marry for the truth." - No Good Wife (Alpha available for Mac and PC.)

Post Reply

Who is online

Users browsing this forum: MonsoonMushroom