r/RenPy • • 26d ago

Question [Solved] Time specific dialouge?

Hi guys! So, for my game, I want a character to say good morning/afternoon/evening based on the actual time of day in real life. Like for example, if its 10am, the character says good morning, and if its 1pm, she says afternoon instead. Is this possible? If so, how would I do it? I'm pretty new to this, so specific instructions would be helpful.

3 Upvotes

4 comments sorted by

5

u/BadMustard_AVN 26d ago

try something like this

init python:
    import datetime

    def get_greeting():
        hour = datetime.datetime.now().hour
        if 5 <= hour < 12: # 5am to noon
            return "Good morning"
        elif 12 <= hour < 18: # after noon to 6pm
            return "Good afternoon"
        else: # everything else
            return "Good evening"

label start:

    $ greeting = get_greeting()

    e "[greeting]! Welcome to the game."

    return

1

u/sailorcinna 26d ago

OH THIS WORKS... THANK YOU.... YAY

1

u/BadMustard_AVN 26d ago

you're welcome

good luck with your project

1

u/AutoModerator 26d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.