How to let players "type" pre-written message (like Emily is Away)?

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
jentalmars
Newbie
Posts: 4
Joined: Wed Oct 18, 2017 1:18 pm
Contact:

How to let players "type" pre-written message (like Emily is Away)?

#1 Post by jentalmars »

Hi, I'm looking for a way for players to type anything on the keyboard and the screen to display more of a creator-written message as the player types. They don't need to type what is written on the message; I'd like for players to be able to type in "asfhkahfkf" or "oidfijjfnf" and still get the same message.

I don't want a delay such as when getting typical user input for names and such. Just keypress any letter = one letter of the message. If you've played Emily is Away, that's exactly what I'd like to do (https://games.renpy.org/game/emily-is-away).

Is there a way to do this in Ren'Py? Thanks in advance :D

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How to let players "type" pre-written message (like Emily is Away)?

#2 Post by Ocelot »

My first thought is to show custom screen with all keys bound to "show next letter" fucntion.
< < insert Rick Cook quote here > >

jentalmars
Newbie
Posts: 4
Joined: Wed Oct 18, 2017 1:18 pm
Contact:

Re: How to let players "type" pre-written message (like Emily is Away)?

#3 Post by jentalmars »

Could you provide me an example of creating a "show next letter" function, if it's not too much trouble? Thanks for replying :)

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How to let players "type" pre-written message (like Emily is Away)?

#4 Post by Ocelot »

Something like:

Code: Select all

default message = ""
default rest_of_message = "I am message"
init python:
    def next_letter():
        global message
        global rest_of_message 
        message += rest_of_message[0]
        rest_of_message = rest_of_message[1:]

screen my_message():
    text message
    key "p" action Function(next_letter)
    # rest of keys
< < insert Rick Cook quote here > >

jentalmars
Newbie
Posts: 4
Joined: Wed Oct 18, 2017 1:18 pm
Contact:

Re: How to let players "type" pre-written message (like Emily is Away)?

#5 Post by jentalmars »

Thank you Ocelot! Sorry for the late reply, I didn't see this till now ^^" I tried it out and it works just like I wanted, thanks again for your help :)

Post Reply

Who is online

Users browsing this forum: bloodzy