Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

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.
Post Reply
Message
Author
User avatar
venerable_bead
Newbie
Posts: 3
Joined: Tue Jul 24, 2018 12:37 pm
Contact:

Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#1 Post by venerable_bead » Tue Jul 24, 2018 1:07 pm

I'm new to RenPy and Python programming. To kick things off I found Uncle Mugen's Cookbook Clock cookbook ATL example via this excellent article:

Tutorial & Code: Analog/Digital Clock as User Defined Display

The article says it was updated in June 2016 and that Uncle Mugen's clock works in RenPy 6.18. It is July 2018 now and I'm using RenPy 7.0.0.

I tried the example clock code; it initially displayed the clock but as the minutes increased the hands stay still.

I managed to get it working by tweaking it a little:

Code: Select all

init:
    $ minutes = 540

image hourhand = "hourhand.png" # Short Clockhand
image minutehand = "minutehand.png" # Long Clockhand
image clockface = "clockface.png" # Clockface

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

transform rotateshort(mins):
    xanchor 0.5
    yanchor 0.5
    xalign 0.5
    yalign 0.5
    rotate (mins*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:
    text "minutes: [minutes]"
    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 "clockface"
        add "minutehand" at rotatelong(minutes)
        add "hourhand" at rotateshort(minutes)
# The game starts here.

label start:
    "What time is it?"
    "Let's look at the clock."
    show screen clock
    "Ah!... Nice 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."
    "HE IS LATE! I KILL HIM!"
    hide screen clock
I know there have been many changes between 6.18 and 7.0.0 but I'm interested to know why the original code no longer works.

Is this change in behaviour documented somewhere? (or is it a bug?)

I'm trying to understand the rules of when variable changes would cause a screen to be updated.

Many thanks :D

Please excuse my RenPy or Forum etiquette ignorance.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#2 Post by xavimat » Tue Jul 24, 2018 3:08 pm

Screens are predicted many times, so updating a variable outside a screen usually is shown immediately in it.

I don't know if has anything to do: try adding parenthesis in the screen definition:

Code: Select all

screen clock():
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
DragonKnight
Regular
Posts: 51
Joined: Sun Nov 12, 2017 10:16 am
Projects: Taboo Hearts
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#3 Post by DragonKnight » Tue Jul 24, 2018 4:15 pm

But, wheres the clock??
Currently working on Taboo Hearts :D
Currently working on Forbidden :D


User avatar
venerable_bead
Newbie
Posts: 3
Joined: Tue Jul 24, 2018 12:37 pm
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#5 Post by venerable_bead » Tue Jul 24, 2018 4:53 pm

Adding the parenthesis to the original code didn't seem to help.
xavimat wrote:
Tue Jul 24, 2018 3:08 pm
Screens are predicted many times, so updating a variable outside a screen usually is shown immediately in it.

I don't know if has anything to do: try adding parenthesis in the screen definition:

Code: Select all

screen clock():

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#6 Post by trooper6 » Tue Jul 24, 2018 4:56 pm

Just a note, My Clock Code (the more complicated version) works in 7.0--my project uses my Clock and if works fine.

Anyhow, using the clock files posted above, I made a project with the working Mugen Code, all updated to 7.0 conventions:

Code: Select all

image hourhand = "images/Clock_1.png" # Short Clockhand
image minutehand = "images/Clock.png" # Long Clockhand
image clockface = "images/Clock_2.png" # Clockface

default minutes = 540

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

transform rotateshort(mins):
    xanchor 0.5
    yanchor 0.5
    xalign 0.5
    yalign 0.5
    rotate (mins*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():
    vbox:
        text "minutes: [minutes]"
        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 "clockface"
            add "minutehand" at rotatelong(minutes)
            add "hourhand" at rotateshort(minutes)
# The game starts here.

label start:
    "What time is it?"
    "Let's look at the clock."
    show screen clock
    "Ah!... Nice 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."
    "HE IS LATE! I KILL HIM!"
    hide screen clock

    return

MugenClockUpdated.zip
(749.65 KiB) Downloaded 19 times
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#7 Post by xavimat » Wed Jul 25, 2018 4:46 am

Another note.
I've tried the old code (posted by OP), and it works Ok too.
It's not good practice now to define variables on init, but it works.

OP's problem is elsewhere.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Uncle Mugen's Cookbook Clock in RenPy 7.0.0??

#8 Post by trooper6 » Wed Jul 25, 2018 12:25 pm

I think it is either a) not having click images at all or b) having clock images but improperly defining them.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: mold.FF