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: 7
Joined: Tue Sep 17, 2019 8:21 pm
Projects: The Ride To Ruin
Deviantart: darxori
Soundcloud: darxori
Contact:

Passwords hidden as Asterisks in renpy?

#1 Post by darxori » Wed May 12, 2021 2:10 pm

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!
~Hey, at least I tried.

CURRENT PROJECT:
THE RIDE TO RUIN
more info to come soon
Image

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1086
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Passwords hidden as Asterisks in renpy?

#2 Post by Ocelot » Wed May 12, 2021 2:44 pm

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: 1588
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 » Wed May 12, 2021 6:22 pm

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: 15642
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 » 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.

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
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

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

Re: Passwords hidden as Asterisks in renpy?

#5 Post by Imperf3kt » Wed May 12, 2021 10:49 pm

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.

Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Latest Blackjack updates

User avatar
IrinaLazareva
Veteran
Posts: 398
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 » Fri May 14, 2021 4:56 pm

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 !
There is a light at the end of the tunnel, just pray it's not a train.

___
TODO: unresolved/нерешённое

Post Reply

Who is online

Users browsing this forum: Google [Bot]