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.
-
chesarty
- Regular
- Posts: 108
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#1
Post
by chesarty » Mon Jan 11, 2021 12:25 pm
I have a line where the player picks their own name and I want the max. characters to be 10, but this doesn't work:
Code: Select all
$ name = renpy.input("Before you can start, let's hear your name.", length=10)
$ name = name.strip()
menu name:
"Did I hear that right, [name]?"
"Yes":
jump nameok
"No":
jump start
It lets you write as many letters as you want, going offscreen...
-
xavimat
- Eileen-Class Veteran
- Posts: 1456
- Joined: Sat Feb 25, 2012 8:45 pm
- Completed: Yeshua, Jesus Life, Cops&Robbers
- Projects: Fear&Love, unknown
- Organization: Pilgrim Creations
- Github: xavi-mat
- itch: pilgrimcreations
- Location: Spain
-
Contact:
#2
Post
by xavimat » Fri Jan 15, 2021 6:10 pm
I can't see any error in the input line. It should work.
Are you sure you have restarted your game after adding the "length" parameter?
On a side note, try to avoid using the same name for different things. You have "name" as a string and also as the name of the menu.
-
chesarty
- Regular
- Posts: 108
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#3
Post
by chesarty » Sat Jan 16, 2021 6:30 pm
xavimat wrote: ↑Fri Jan 15, 2021 6:10 pm
I can't see any error in the input line. It should work.
Are you sure you have restarted your game after adding the "length" parameter?
On a side note, try to avoid using the same name for different things. You have "name" as a string and also as the name of the menu.
I rebooted the game multiple times and it didn't change the outcome :/
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3250
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#4
Post
by Imperf3kt » Sat Jan 16, 2021 7:23 pm
chesarty wrote: ↑Sat Jan 16, 2021 6:30 pm
xavimat wrote: ↑Fri Jan 15, 2021 6:10 pm
I can't see any error in the input line. It should work.
Are you sure you have restarted your game after adding the "length" parameter?
On a side note, try to avoid using the same name for different things. You have "name" as a string and also as the name of the menu.
I rebooted the game multiple times and it didn't change the outcome :/
As far as I am aware, Ren'Py doesn't accept anything after "menu"
https://renpy.org/doc/html/store_variab ... l#var-menu
So try changing your code to this. (I removed the word
name after
menu)
Code: Select all
$ name = renpy.input("Before you can start, let's hear your name.", length=10)
$ name = name.strip()
menu:
"Did I hear that right, [name]?"
"Yes":
jump nameok
"No":
jump start
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally
-
PyTom
- Ren'Py Creator
- Posts: 15575
- 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:
#5
Post
by PyTom » Sun Jan 17, 2021 1:27 am
At least for me, on the main branch of Ren'Py, the example in the first post is working fine, it's not letting me enter more than 10 characters.
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
-
chesarty
- Regular
- Posts: 108
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#6
Post
by chesarty » Thu Jan 21, 2021 1:52 pm
Ok I'm back, and I think I figured something out:
When I add a blinking caret to the input screen (I don't automatically have it for some reason?), that's when the length argument stops working. When I get rid of the caret, the input only lets you type in 10 characters. What's the reason to this?
-
PyTom
- Ren'Py Creator
- Posts: 15575
- 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:
#7
Post
by PyTom » Thu Jan 21, 2021 2:56 pm
Do you have the example of what you did to add the blinking caret?
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
-
chesarty
- Regular
- Posts: 108
- Joined: Sat Aug 25, 2018 3:07 am
- Completed: 0
-
Contact:
#8
Post
by chesarty » Fri Jan 22, 2021 12:16 pm
PyTom wrote: ↑Thu Jan 21, 2021 2:56 pm
Do you have the example of what you did to add the blinking caret?
For the input screen I added this line:
and defined the animation blink.
Turns out, since I only need one input in the whole game, I decided to add "input length 10" into the input screen itself instead of the one particular menu. Playing around with the order of these eventually got me to successfully get everything working as it should. There was a little bug where if I put "input caret blink" before "input length 10", the input text would go on a separate line from the caret...
Anyhow, it's all working now!
-
Alex
- Lemma-Class Veteran
- Posts: 2605
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#9
Post
by Alex » Fri Jan 22, 2021 1:53 pm
chesarty wrote: ↑Fri Jan 22, 2021 12:16 pm
...
Try this sample
Code: Select all
image blink:
Solid("#0c0")
size (20, 3)
blink_tr
transform blink_tr:
yalign 1.0
block:
alpha 1.0
linear 0.5 alpha 0.0
linear 0.5 alpha 1.0
repeat
screen test_input():
frame:
xysize(300, 100)
align(0.05, 0.2)
hbox:
align(0.0, 0.5)
text ">>: " color "#0c0" size 35
input length 10 caret 'blink' color "#fff" size 35
# The game starts here.
label start:
"..."
call screen test_input
$ res = _return
"[res] ?!"