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.
I'm also using a messaging system. And I wanted is to show the time the player received the message.
Let's just say that when the person was playing it was 13:53.
If I add in the message "{show image=mytimes}" it will show what time it is the moment you click the message. But as time goes by, the clock will abviously keep changing. "13:53" will become 13:54, 13:55, etc.
Is there a way I can "freeze" the time the person received the message?
Like, if it was 13:53 when I clicked the messsage, it will keep showing "13:53" in the message.
Thank you
Last edited by Nanahs on Tue Oct 30, 2018 6:07 pm, edited 1 time in total.
You should be able to simply convert the time to a string and store it in a variable, I don't know how your messaging system is coded so I can't give you exact advice but, this is a way to do it:
DannX wrote: ↑Fri Oct 19, 2018 8:45 am
You should be able to simply convert the time to a string and store it in a variable, I don't know how your messaging system is coded so I can't give you exact advice but, this is a way to do it:
I'm trying to do it, but the time keeps progressing
I wanted the time to "freeze". So that if received the message at 9:46, the text will keep showing "9:46" even though real time passes.
DannX wrote: ↑Fri Oct 19, 2018 8:45 am
You should be able to simply convert the time to a string and store it in a variable, I don't know how your messaging system is coded so I can't give you exact advice but, this is a way to do it:
You need to "attach" the time to the text of the message. I don't understand russian so I can't read the comments, but after some testing I think that what you need to change is the msg() function in messenger.rpy:
def msg(txt, who=False, sound=False):
txt += "\n{}".format(str(time.strftime('%H:%M'))) # Add this line before the rest of the function
store.m_msg.append((who, txt, sound))
store.yadj.value = store.yadj.range+300
renpy.restart_interaction()
if who:
renpy.play("new_message.mp3", "sound")
renpy.pause()
This will append a linebreak, and then the current time to the end of the string, the str() is to make sure the text doesn't keep changing as time passes.
DannX wrote: ↑Wed Oct 24, 2018 3:19 pm
You need to "attach" the time to the text of the message. I don't understand russian so I can't read the comments, but after some testing I think that what you need to change is the msg() function in messenger.rpy:
def msg(txt, who=False, sound=False):
txt += "\n{}".format(str(time.strftime('%H:%M'))) # Add this line before the rest of the function
store.m_msg.append((who, txt, sound))
store.yadj.value = store.yadj.range+300
renpy.restart_interaction()
if who:
renpy.play("new_message.mp3", "sound")
renpy.pause()
This will append a linebreak, and then the current time to the end of the string, the str() is to make sure the text doesn't keep changing as time passes.
Thank you so much! In case I wanted to use this code in a normal text to show what time it is, like:
That last one is shorter, but harder to read and type.
Thank you! It worked!
The only problem is that if the first message is at 15:13, the time endeed will "freeze". But the other following messages will stay stuck at "15:13" as well. Maybe I did something wrong? But that's ok hah
Just one last thing (sorry, I'm asking too much hah). I was trying to change the letter size, so the time wouldn't be as big as the letters. But it's not working.