renpy.input length not working?

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
User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

renpy.input length not working?

#1 Post by chesarty »

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...

User avatar
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:

Re: renpy.input length not working?

#2 Post by xavimat »

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.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: renpy.input length not working?

#3 Post by chesarty »

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 :/

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: renpy.input length not working?

#4 Post by Imperf3kt »

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.

Current project: GGD Mentor

Twitter

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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:

Re: renpy.input length not working?

#5 Post by PyTom »

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
Software > Drama • https://www.patreon.com/renpytom

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: renpy.input length not working?

#6 Post by chesarty »

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?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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:

Re: renpy.input length not working?

#7 Post by PyTom »

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
Software > Drama • https://www.patreon.com/renpytom

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: renpy.input length not working?

#8 Post by chesarty »

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:

Code: Select all

            input caret "blink"
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!

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: renpy.input length not working?

#9 Post by Alex »

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] ?!"

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], solarisdreams