Page 1 of 1

renpy.input length not working?

Posted: Mon Jan 11, 2021 12:25 pm
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...

Re: renpy.input length not working?

Posted: Fri Jan 15, 2021 6:10 pm
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.

Re: renpy.input length not working?

Posted: Sat Jan 16, 2021 6:30 pm
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 :/

Re: renpy.input length not working?

Posted: Sat Jan 16, 2021 7:23 pm
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
            

Re: renpy.input length not working?

Posted: Sun Jan 17, 2021 1:27 am
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.

Re: renpy.input length not working?

Posted: Thu Jan 21, 2021 1:52 pm
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?

Re: renpy.input length not working?

Posted: Thu Jan 21, 2021 2:56 pm
by PyTom
Do you have the example of what you did to add the blinking caret?

Re: renpy.input length not working?

Posted: Fri Jan 22, 2021 12:16 pm
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!

Re: renpy.input length not working?

Posted: Fri Jan 22, 2021 1:53 pm
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] ?!"