Page 1 of 1
Passwords hidden as Asterisks in renpy?
Posted: Wed May 12, 2021 2:10 pm
by darxori
Hello, I was wondering if there's a way to hide input text from the player with ******* or similar characters because I'm trying to create a fake log in interface for my game, but I at least want it to feel real.
I looked and there is something called stdiomask
https://pypi.org/project/stdiomask/#files for python that does this (I'm not exactly sure how it works) but idk how I would go about using it in Ren'Py or if that's even possible.
If there is another way to do it or code examples, any help would be appreciated, Thanks!
Re: Passwords hidden as Asterisks in renpy?
Posted: Wed May 12, 2021 2:44 pm
by Ocelot
If you want quick and dirty solution, you can use a font file that displays all characters as asterisks. Just take the font you want and replace all characters in it with asterisks using any font editor.
Re: Passwords hidden as Asterisks in renpy?
Posted: Wed May 12, 2021 6:22 pm
by Remix
Or put the input in a fixed with a text (with solid background) directly over it that just shows * times the input length.
Re: Passwords hidden as Asterisks in renpy?
Posted: Wed May 12, 2021 9:37 pm
by PyTom
I've added support for this to Ren'Py. It'll show up in tomorrow's nightly and the next 7.4.5 release.
With the change, it's possible to write:
Code: Select all
$ password = renpy.input("Enter Password:", mask="•")
Re: Passwords hidden as Asterisks in renpy?
Posted: Wed May 12, 2021 10:49 pm
by Imperf3kt
I've personally never seen the point of masking passwords. If somebody is able to see your screen, surely they can see your hand typing on your keyboard too?
Personally, I dislike being unable to check that I've typed the password correctly, will you include a way for the player to disable or temporarily hide the mask so they can check?
Re: Passwords hidden as Asterisks in renpy?
Posted: Fri May 14, 2021 4:56 pm
by IrinaLazareva
PyTom wrote: ↑Wed May 12, 2021 9:37 pm
I've added support for this to Ren'Py. It'll show up in tomorrow's nightly and the next 7.4.5 release.
Thank you so much for this !
Imperf3kt wrote: ↑Wed May 12, 2021 10:49 pm
Personally, I dislike being unable to check that I've typed the password correctly, will you include a way for the player to disable or temporarily hide the mask so they can check?
4 example...
Code: Select all
default sword = ""
default mkey = '12345'
default showpass = False
screen derparol():
frame:
align(.5,.5)
vbox:
textbutton '✘' action Quit(False) xalign 1.0 text_size 12
text 'Enter password:' xalign .5
input mask (None if showpass else '*') length 9 value VariableInputValue('sword', True, True)
hbox:
spacing 5
textbutton ('✘' if showpass else '✔') action ToggleVariable('showpass') text_size 14 text_color '#2f0'
text 'show password' size 15
key "K_RETURN" action If(sword==mkey, Return(), SetVariable('sword', ''))
label splashscreen:
call screen derparol
return
warning: this code working in nightly version (7.4.5) only !