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.
Nanahs
Veteran
Posts: 310 Joined: Wed Aug 22, 2018 5:50 pm
Contact:
#1
Post
by Nanahs » Thu Oct 11, 2018 8:08 am
In my game I let the player choose their name with this code.
Code: Select all
define e = Character("[name]")
$ name = renpy.input("What's your name?")
$ name = name.strip()
There are also a few other moments I let them answer by typing.
The problem is, if they click on the screen it jumps to another label. And the "[name]" becomes blanck.
So instead of a line for example being "Hello Jhon! Welcome to the game!" it would be "Hello _! Welcome to the game." hah
So, is there a way I can "block" the person from jumping the scene before they asnwer to the question?
Thank you
Last edited by
Nanahs on Sun Oct 14, 2018 10:22 am, edited 1 time in total.
xavimat
Eileen-Class Veteran
Posts: 1461 Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:
#2
Post
by xavimat » Thu Oct 11, 2018 10:57 am
If I understand it well, that does not happen when they "click" on the screen, but when they press "Return" key on keyboard.
Here two solutions: one to ask again and another to get a default name automatically:
Code: Select all
# SOLUTION 1
default name = ""
define e = Character("[name]")
label start:
while name == "":
$ name = renpy.input("What's your name?").strip()
Code: Select all
# SOLUTION 2
default name = ""
define e = Character("[name]")
label start:
$ name = renpy.input("What's your name?").strip() or "Johnny"
Nanahs
Veteran
Posts: 310 Joined: Wed Aug 22, 2018 5:50 pm
Contact:
#3
Post
by Nanahs » Sun Oct 14, 2018 10:18 am
xavimat wrote: ↑ Thu Oct 11, 2018 10:57 am
If I understand it well, that does not happen when they "click" on the screen, but when they press "Return" key on keyboard.
Here two solutions: one to ask again and another to get a default name automatically:
Code: Select all
# SOLUTION 1
default name = ""
define e = Character("[name]")
label start:
while name == "":
$ name = renpy.input("What's your name?").strip()
Code: Select all
# SOLUTION 2
default name = ""
define e = Character("[name]")
label start:
$ name = renpy.input("What's your name?").strip() or "Johnny"
Thank you so much! It worked
Users browsing this forum: Google [Bot] , Majestic-12 [Bot]