How to define this time code?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

How to define this time code?

#1 Post by Nanahs »

The "normal" text code is this one:

Code: Select all

text "%s"%(txt) style "txt_base"
To add current time to the message I'm using this:

Code: Select all

def msg(txt, who=False, sound=False):
    txt += "\n{}".format(str(time.strftime('%H:%M'),size=17))
The time appears with my message. The problem it that it shows right after the text, in the same line.
For example:

"Hi Anna! How are you? 10:53"

I wanted the time to show like that (always bellow the text, at right corner):

Image

Maybe I could define this time function separately, call it like "current_time" and try to make something like this?

Code: Select all

text "%s"%(txt)% *ADD CURRENT TIME HERE* style 'txt_base'
It didn't work though.
Does anyone have an idea?

Thanks.

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How to define this time code?

#2 Post by Nanahs »

This code:

Code: Select all

init -1 python:
    import time
    t = time.strftime('%H:%M')
And also this code:

Code: Select all

    $ from datetime import datetime
    $ t = datetime.now().strftime('%H:%M')
    $ renpy.say(None, t)
They both give you the current time. But time "freezes". If the first message was at "10:27", the following messages will appear as "10:27", even if real time passes.

Actually these codes would be better to what I want to do (especially the second one). Since you can add "[t]" where I want the time to appear.
The problem is that the time keeps "frozen". It doesn't progress.
What should I do?

Thanks.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]