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.
-
DesertFox
- Regular
- Posts: 196
- Joined: Sun Jul 28, 2013 1:29 pm
- Completed: Over The Hills And Far Away
- Projects: My Little Dictator
- Organization: WarGirl Games
-
Contact:
#1
Post
by DesertFox » Sat Oct 17, 2015 10:43 pm
I've defined a custom input screen and I'm using booleans to decide what should happen based on what's entered. However, the booleans initiate once a certain string has been entered rather than on the player hitting the 'ENTER' key. Is there a definition I can use to include the enter key within the boolean, as part of the string?
Code: Select all
screen myinput():
button:
id "name_input1"
action NullAction()
add Input(default=firstname, changed=name_func, button=renpy.get_widget("name_input","name_input1"))
if firstname == "jon":
timer 0.25 action Start()
etc.
-
philat
- Eileen-Class Veteran
- Posts: 1853
- Joined: Wed Dec 04, 2013 12:33 pm
-
Contact:
#2
Post
by philat » Sat Oct 17, 2015 11:00 pm
Two things I would explore (no guarantees, obvs):
1. Why not just return the value from the screen and initiate all the checks outside of the screen?
2. You can assign an action to the enter key that sets a placeholder variable to True/False so that you're checking "if firstname == "jon" and entervariable:" rather than just firstname.
http://www.renpy.org/doc/html/screens.html#key
-
PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
-
Contact:
#3
Post
by PyTom » Sat Oct 17, 2015 11:18 pm
The processing of the enter key is nearly hard-coded in there. (You could remove it in the keymap, but I don't think SDL would translate the enter key into \r or \n.) There wouldn't be a good way to include it in the string. If you really must do something like this, you probably want to use a CDD that handles pygame.KEYDOWN events.
What are you actually trying to accomplish?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama •
https://www.patreon.com/renpytom
-
DesertFox
- Regular
- Posts: 196
- Joined: Sun Jul 28, 2013 1:29 pm
- Completed: Over The Hills And Far Away
- Projects: My Little Dictator
- Organization: WarGirl Games
-
Contact:
#4
Post
by DesertFox » Mon Oct 19, 2015 7:54 pm
PyTom wrote:The processing of the enter key is nearly hard-coded in there. (You could remove it in the keymap, but I don't think SDL would translate the enter key into \r or \n.) There wouldn't be a good way to include it in the string. If you really must do something like this, you probably want to use a CDD that handles pygame.KEYDOWN events.
What are you actually trying to accomplish?
I'm using the input on a menu screen and don't really want it to jump to a label every time something is entered, since there are options such as opening Help() and similar. There are also issues with the definition of 'firstname' when I place them inside labels.
I want the player to have a limited number of things they can enter and for what they enter to only initiate upon the player hitting the Enter key. Like you said, '\n' doesn't register. There's probably no simple way to work around this.
-
philat
- Eileen-Class Veteran
- Posts: 1853
- Joined: Wed Dec 04, 2013 12:33 pm
-
Contact:
#5
Post
by philat » Mon Oct 19, 2015 9:22 pm
I don't know any other specifics of what you're doing, so perhaps there's a reason you can't use a keymap for this, but the following works in an empty project.
Code: Select all
init -1 python:
firstname = "default"
entervar = False
def name_func(newstring):
store.firstname = newstring
store.entervar = False
renpy.restart_interaction()
screen myinput():
vbox:
button:
xminimum 150
id "name_input1"
action NullAction()
add Input(default=firstname, changed=name_func, button=renpy.get_widget("name_input","name_input1"))
if firstname == "jon" and entervar:
text "jon"
else:
text "default"
key "K_RETURN" action SetVariable("entervar", True)
-
DesertFox
- Regular
- Posts: 196
- Joined: Sun Jul 28, 2013 1:29 pm
- Completed: Over The Hills And Far Away
- Projects: My Little Dictator
- Organization: WarGirl Games
-
Contact:
#6
Post
by DesertFox » Mon Oct 19, 2015 9:42 pm
That works perfectly, thank you!

Users browsing this forum: Google [Bot]