Time of day button, how to add time

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
obi_dev
Newbie
Posts: 7
Joined: Wed Aug 16, 2017 9:12 pm
Contact:

Time of day button, how to add time

#1 Post by obi_dev »

So.. I tried googling and searching and I guess I couldn't google right, or find exactly what I need. Maybe it's the structure of my code or the idea I am trying to do.

So, in short, I have a gui setup for the user. on the gui, there is a day/time area. I create a button to "wait" to progress the time.
When trying to make the "wait" button work, I have been a bit unsuccessful.

Function

Code: Select all

class Time(object):
        def __init__(self):
            self._day = 1
            self._time = 1

            self._days_passed = 0
            
	def advance_time(self):
            # add time
            self._time += 1

            # if it's evening
            if self._time > 3:
                self._time = 1 # go back to Morning
                self._day += 1 # go to next day
                self._days_passed += 1 # add to day count

                # if it's sunday
                if self._day > 7:
                    self._day = 1
            # else add time
            else:
                self._time += 1
Next, I have the wait button

Code: Select all

frame:
            style "wait"
            imagebutton:
                action time.advance_time
                idle "gui/footer/wait.png"
                hover "gui/footer/wait_hover.png"
                focus_mask True
                hovered [ Show("header_txt", menuText="Wait",  ht_x=221) ]
                unhovered [Hide("header_txt")]
When using it like this, the button works, but only after I hover off of the button



It may be a design flaw, but eventually, when advancing time, it would cause different action to occur, i.e. change the scene from day to night, move characters to different rooms, etc.

But, I am not sure how to actually go about that yet. I've tried creating a label to add the call to the function, but it just sends me to the main menu.
If I want to make this correctly, what is the best way to go about..
Example:
Time is Monday - Morning
Clicking wait moves to Monday - Afternoon
once it progresses to Monday - Afternoon, I need to make other adjustments, such as screen changes and so on. Any good examples out there?

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Time of day button, how to add time

#2 Post by Divona »

Code: Select all

            imagebutton:
                action Function(time.advance_time)
There is this Dating Sim Engine (DSE) I have seen in this forum. A bit old, but maybe you could learn something from it?
Completed:
Image

obi_dev
Newbie
Posts: 7
Joined: Wed Aug 16, 2017 9:12 pm
Contact:

Re: Time of day button, how to add time

#3 Post by obi_dev »

Divona wrote: Sun Oct 01, 2017 10:24 pm

Code: Select all

            imagebutton:
                action Function(time.advance_time)
There is this Dating Sim Engine (DSE) I have seen in this forum. A bit old, but maybe you could learn something from it?
I knew it was going to be something simple! Thanks for the example as well. I have been trying to download random games to see how people are coding their games.

Post Reply

Who is online

Users browsing this forum: No registered users