Passwords hidden as Asterisks in renpy?

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
darxori
Newbie
Posts: 8
Joined: Tue Sep 17, 2019 8:21 pm
Projects: memoria-machina.com
Soundcloud: darxori
itch: darxori
Contact:

Passwords hidden as Asterisks in renpy?

#1 Post 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!

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Passwords hidden as Asterisks in renpy?

#2 Post 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.
< < insert Rick Cook quote here > >

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Passwords hidden as Asterisks in renpy?

#3 Post 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.
Frameworks & Scriptlets:

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: Passwords hidden as Asterisks in renpy?

#4 Post 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="•")
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
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Passwords hidden as Asterisks in renpy?

#5 Post 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?
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
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Passwords hidden as Asterisks in renpy?

#6 Post 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 !

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]