This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.

Adding a manually controlled Analog Clock

This cookbook recipe will add a manually controlled analog clock on your screen. This can be helpful when your game takes place over a clearly defined time period and you want to show the current game time in the UI for story or gameplay reasons, in a more stylish manner than a text display.

But first, please download and copy these images below to your game directory (or wherever you save your images)

Image:Clock.png|Clock Image:Clock_1.png|Clock_1 Image:Clock_2.png|Clock_2

Now copy the code below inside your script.

image clock = "clock.png" # Short Clockhand
image clock_1 = "clock_1.png" # Long Clockhand
image clock_2 = "clock_2.png" # Clockface

transform rotateshort:
    xanchor 0.5
    yanchor 0.5
    xalign 0.5
    yalign 0.5
    rotate (minutes*6)
transform rotatelong:
    xanchor 0.5
    yanchor 0.5
    xalign 0.5
    yalign 0.5
    rotate (minutes*0.5)

transform alpha_dissolve:
    alpha 0.0
    linear 0.5 alpha 1.0
    on hide:
        linear 0.5 alpha 0
    # This is to fade in the clock.

screen clock:
    frame at alpha_dissolve:
        xmaximum 250 # X size of clock graphic
        ymaximum 250 # Y size of clock graphic
        xalign 0.99 # X placement on screen
        yalign 0.02 # Y placement on screen
        add "clock_2"
        add "clock_1" at rotatelong
        add "clock" at rotateshort

To modify the way the clock enters the screen when shown, the transform alpha_dissolve must be changed. Changing linear 0.5 to linear 1.0 will double the time it fades in. You can use other ATL to make the clock slide onto the screen instead of dissolving.

Unlike your typical clock, this one will need the time to be defined manually in order to function.


After putting the previous code inside your game script, you now must show the clock for it to be visible.

You show it like this...

label start:
    "What time is it?"
    "Let's look at the clock."

    show screen clock

    "Ah!... Nice clock!"

So the words [ show screen clock ] tell Ren'py to "show" the clock.

To hide the clock again just use [ hide screen clock ].


Of course, for this Analog Clock to be useful you have to be able to set the time and dictate the time. But before that, please copy the code below in your game script.

    $ minutes = 0

So what is this? You see, this is the code where you dictate the starting time of the clock... in this case 0 minutes or 12:00 Midnight. If you wanted to change the starting time to 9:00AM you will have to calculate how many minutes have passed from 12:00 Midnight till 9:00AM... in this case it's 540 minutes so you will have to write the above code like this (see below)

    $ minutes = 540


Let's say you are in the middle of the game and your current time is set at 540 (9:00AM) and you wanted to add 2 minutes to the clock. You will have to write something like this (see below)

  $ minutes += 2

The code above adds additional two minutes to the current time count and the analog clock will now display the time 9:02AM.

Here is an good example of how to use Analog Clock in actual. In this code we assume you set your clock to 9:00AM or [$ minutes = 540]

label start:

    show screen clock

    "It is already 9:00AM."
    "He is very late."
    "But he is my friend so I will wait."
    $ minutes += 2
    "Two minutes has passed."
    $ minutes += 2
    "Four minutes has passed."
    $ minutes += 2
    "Six minutes has passed."

    hide screen clock

So the above code will show the analog clock with dissolve at 9:00AM then it will move by two minutes, and another two minutes, and another tow minutes.

For your convenience, I also add a sort of guide to make adding minutes a lot easier.

# 12:00 MN - 0
# 1:00  AM - 60
# 2:00  AM - 120
# 3:00  AM - 180
# 4:00  AM - 240
# 5:00  AM - 300
# 6:00  AM - 360
# 7:00  AM - 420
# 8:00  AM - 480
# 9:00  AM - 540
# 10:00 AM - 600
# 11:00 AM - 660
# 12:00 NN - 720 
# 1:00  PM - 780
# 2:00  PM - 840
# 3:00  PM - 900
# 4:00  PM - 960
# 5:00  PM - 1020
# 6:00  PM - 1080
# 7:00  PM - 1140
# 8:00  PM - 1200
# 9:00  PM - 1260
# 10:00 PM - 1320
# 11:00 PM - 1380