Page 1 of 1

Having problems with making a "Day cycle" code

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

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

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

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

Posted: Tue Feb 13, 2018 4:31 pm
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.