Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#16 Post by Remix »

You want to just jump to morning of next day? Can be simplified so we do not count our start point.

# reset time of day (so we are back at 'morning')
$ clock.time_of_day = ["morning", "noon", "evening", "night"]
$ clock.day += 1

Subnote: Maybe add a method to the class that does it and call that ... def sleep_until_morning(self):

Your question:
Short of using a more complex system, the way you are going is probably best, though just one if:else should do
if not kitchenintro:
... "cannot sleep"
else:
... do the above
Frameworks & Scriptlets:

xplosion
Newbie
Posts: 10
Joined: Sat Jul 21, 2018 3:49 pm
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#17 Post by xplosion »

Remix wrote: Sat Aug 04, 2018 9:26 am You want to just jump to morning of next day? Can be simplified so we do not count our start point.

# reset time of day (so we are back at 'morning')
$ clock.time_of_day = ["morning", "noon", "evening", "night"]
$ clock.day += 1

Subnote: Maybe add a method to the class that does it and call that ... def sleep_until_morning(self):

Your question:
Short of using a more complex system, the way you are going is probably best, though just one if:else should do
if not kitchenintro:
... "cannot sleep"
else:
... do the above
Damn I didn't think of resetting the time, your method is way better!

Then if you agree about my way of doing events I guess I will keep going on it.

Thanks for the input

Danger_Lizard
Newbie
Posts: 3
Joined: Fri Jan 10, 2020 4:43 pm
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#18 Post by Danger_Lizard »

Hi, I am trying to build a calendar from this code, but I need to months and years as well as days and weeks. Would I simply add month and year to the init and then define them like below?

Code: Select all

init python:
    class day_time(object):
        def __init__(self):
            self.year = 1 # set to starting year
            self.month = 1 # set to starting month
            self.month_names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] # month names from start to end
            self.days_count = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # number of days in each month
            self.day = 1 # set this to whatever starting day is
            self.weekdays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] # arrange these so first weekday goes first
            self.time_of_day = ["Early Morning","Morning", "Noon", "Afternoon", "Evening", "Late Evening", "Night"] # add or remove to increase time of day slots
            self.end_of_day = self.time_of_day[-1] # automatically picks last slot as end of day
            
            
@property
def month_number(self):
      return self._month + 1
            
@property
def month(self):
      return self.month_names[self.month]
 
I have tried to test this code, but I seem to be missing something for it to actually implement the month and year in the calendar. Any assistance will be greatly appreciated.

Tesspolar
Newbie
Posts: 21
Joined: Fri Mar 20, 2020 11:37 am
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#19 Post by Tesspolar »

Is there anyway to add hours of the day instead of morning, noon etc..?

And how can I specify choice or event that has to happen between like 10am and 2pm?

Thanks alot

advance2
Newbie
Posts: 8
Joined: Thu Apr 12, 2018 5:10 pm
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#20 Post by advance2 »

I have two questions:
1. Right now script have time of day, day of week, and day count. how to count weeks (week 1, week 2, etc.)
2. how to advance time of day, so that you can advance from morning to night on text button, but you can not advance from night to morning on text button, but for example if main character go to sleep time advances from night to morning.

darthi86
Newbie
Posts: 2
Joined: Fri Jan 08, 2021 10:45 am
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#21 Post by darthi86 »

Hi!
I'm also new to python. I used the code of kivik and so far everything is working.
I want to show a HUD, where the Time and the Weekday are shown.

So far I did this:

Code: Select all

screen day_time_map:

    zorder 103

    if [clock.time]=="morning":
        add Transform("morning.png", xpos=130, ypos=62)

    if [clock.time]=="noon":
        add Transform("noon.png", zoom=.8)

    if [clock.time]=="afternoon":
        add Transform("evening.png", zoom=.8)
    if [clock.time]=="evening":
        add Transform("evening.png", zoom=.8)
    if [clock.time]=="night":
        add Transform("night.png", zoom=.8)



screen week_day_map:

    zorder 103

    if [clock.weekday]=="Monday":

        add Transform("monday_button.png", xpos=130, ypos=12)

    if [clock.weekday]=="Tuesday":

        add Transform("tuesday_button.png", zoom=.8)

    if [clock.weekday]=="Wednesday":

        add Transform("wednesday_button.png", zoom=.8)

    if [clock.weekday]=="Thursday":
        add Transform("thursday_button.png", zoom=.8)

    if [clock.weekday]=="Friday":

        add Transform("friday_button.png", zoom=.8)

    if [clock.weekday]=="Saturday":

        add Transform("saturday_button.png", zoom=.8)

    if [clock.weekday]=="Sunday":

        add Transform("sunday_button.png", zoom=.8)
I call screen week_day_map and screen day_time_map but both don't show up. What am I doing wrong here?
Any help or suggestion would be appreciated. :)

darthi86
Newbie
Posts: 2
Joined: Fri Jan 08, 2021 10:45 am
Contact:

Re: Simple script for a day/night cycle, or rather a morning, noon, evening & night cycle

#22 Post by darthi86 »

darthi86 wrote: Fri Jan 08, 2021 10:51 am Hi!
I'm also new to python. I used the code of kivik and so far everything is working.
I want to show a HUD, where the Time and the Weekday are shown.

So far I did this:

Code: Select all

screen day_time_map:

    zorder 103

    if [clock.time]=="morning":
        add Transform("morning.png", xpos=130, ypos=62)

    if [clock.time]=="noon":
        add Transform("noon.png", zoom=.8)

    if [clock.time]=="afternoon":
        add Transform("evening.png", zoom=.8)
    if [clock.time]=="evening":
        add Transform("evening.png", zoom=.8)
    if [clock.time]=="night":
        add Transform("night.png", zoom=.8)



screen week_day_map:

    zorder 103

    if [clock.weekday]=="Monday":

        add Transform("monday_button.png", xpos=130, ypos=12)

    if [clock.weekday]=="Tuesday":

        add Transform("tuesday_button.png", zoom=.8)

    if [clock.weekday]=="Wednesday":

        add Transform("wednesday_button.png", zoom=.8)

    if [clock.weekday]=="Thursday":
        add Transform("thursday_button.png", zoom=.8)

    if [clock.weekday]=="Friday":

        add Transform("friday_button.png", zoom=.8)

    if [clock.weekday]=="Saturday":

        add Transform("saturday_button.png", zoom=.8)

    if [clock.weekday]=="Sunday":

        add Transform("sunday_button.png", zoom=.8)
I call screen week_day_map and screen day_time_map but both don't show up. What am I doing wrong here?
Any help or suggestion would be appreciated. :)
Okay i figured it out:

Code: Select all

screen day_time_map:

    zorder 103

    if clock.time=="morning":
        add Transform("morning.png", xpos=130, ypos=62)

    if clock.time=="noon":
        add Transform("noon.png", zoom=.8)

    if clock.time=="afternoon":
        add Transform("evening.png", zoom=.8)
    if clock.time=="evening":
        add Transform("evening.png", zoom=.8)
    if clock.time=="night":
        add Transform("night.png", zoom=.8)



screen week_day_map:

    zorder 103

    if clock.weekday=="Monday":

        add Transform("monday_button.png", xpos=130, ypos=12)

    if clock.weekday=="Tuesday":

        add Transform("tuesday_button.png", zoom=.8)

    if clock.weekday=="Wednesday":

        add Transform("wednesday_button.png", zoom=.8)

    if clock.weekday=="Thursday":
        add Transform("thursday_button.png", zoom=.8)

    if clock.weekday=="Friday":

        add Transform("friday_button.png", zoom=.8)

    if clock.weekday=="Saturday":

        add Transform("saturday_button.png", zoom=.8)

    if clock.weekday=="Sunday":

        add Transform("sunday_button.png", zoom=.8)
I was adding the brackets, but leaving them works like a charm :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]