Setting up the Date Indicator

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
Zeekee
Regular
Posts: 67
Joined: Wed Jul 23, 2014 10:17 pm
Projects: No One But You, The Anomaly
Organization: Annexe Interactive
Skype: ytmnd111
Soundcloud: zomgaarh
Location: USAF Academy, CO
Contact:

Setting up the Date Indicator

#1 Post by Zeekee »

Hey, all! So, I've been racking my brain trying to figure out how to get the in-game date indicator to display properly. This is the code I have for it so far:

Code: Select all

screen dateandtime:
    add "GUI/date_back.png":
        xpos 940
        ypos 0
    text "April":
        xpos 1000
        ypos 50
        size 28
        outlines [(2,color('#0009'),1,1)]
    text "Wednesday":
        xpos 1010
        ypos 100
        size 18
        outlines [(2,color('#0009'),1,1)]
    text "15".zfill(2):
        xpos 1160
        ypos 48
        size 52
        outlines [(2,color('#0009'),1,1)]
I use the following to call it in the script:

Code: Select all

show screen dateandtime
Unfortunately, whenever I try and use variables instead of static values like "April" or "Wednesday," Renpy returns an error. This is what I tried doing:

Code: Select all

show screen dateandtime("April", "Wednesday", "15")

Code: Select all

screen dateandtime (str month, str week, str day):
    add "GUI/date_back.png":
        xpos 940
        ypos 0
    text "[month]":
        xpos 1000
        ypos 50
        size 28
        outlines [(2,color('#0009'),1,1)]
    text "[week]":
        xpos 1010
        ypos 100
        size 18
        outlines [(2,color('#0009'),1,1)]
    text "[day]".zfill(2):
        xpos 1160
        ypos 48
        size 52
        outlines [(2,color('#0009'),1,1)]
Which returns:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/game_char.rpy", line 170: expected ',' not found.
    screen dateandtime (str month, str week, str day):
                            ^

Ren'Py Version: Ren'Py 6.99.10.1227
To be fair, I haven't used Python at all before delving into Renpy. I believe that I may be mixing up syntax with other languages, but I can't seem to find what I'm looking for in the online documentation.

Any help would be much appreciated! :)
"When people sometimes misquote me, I don't know if they understand what I'm saying."
-Tommy Wiseau

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: Setting up the Date Indicator

#2 Post by Divona »

Python does not need explicit declaration as it does that automatically when you assign a value to a variable. All you have to do is this:

Code: Select all

screen dateandtime(month, week, day):
Completed:
Image

User avatar
Zeekee
Regular
Posts: 67
Joined: Wed Jul 23, 2014 10:17 pm
Projects: No One But You, The Anomaly
Organization: Annexe Interactive
Skype: ytmnd111
Soundcloud: zomgaarh
Location: USAF Academy, CO
Contact:

Re: Setting up the Date Indicator

#3 Post by Zeekee »

Thanks, Divona! Works like a charm :)
"When people sometimes misquote me, I don't know if they understand what I'm saying."
-Tommy Wiseau

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]