Best way to realize a password field

  • #10, z sebastianTuesday, 02. May 2017, 06:32 hodinky 8 years ago
    @marvel: 
    instead of deleting less than and greater than here in the forums you should replace them by < and >
    ( & lt ; and & gt ; ) 

    Kapitán

    2346 Posts


  • #11, z marvelTuesday, 02. May 2017, 08:14 hodinky 8 years ago
    Alright,
    thanks a lot guys. Basically it works now, but I have these problems:

    1. How do I find out if it's the right password?
    Is there any function to compare to strings and set a condition to true then?

    2. The cursor is messed up
    I created a loop for the cursor showing an additional "|"... and made a small pause of 500ms after that. But when I type now, also the typing gets paused ^^

    3. Pressing Enter
    How could I check for the right passwort, when the user presses "Enter". This would be the normal behavior - like in the windows login.



    Zabiják klíčů

    599 Posts

  • #12, z sebastianTuesday, 02. May 2017, 08:22 hodinky 8 years ago
    just check in an Lua if :

    if Values["password"].String == "secret_password" then
      Conditions["password_correct"].ConditionValue = true
    else
    Conditions["password_correct"].ConditionValue = false
    end

    when pressing the Confirmation button or after each keypress.

    In VS itself ita also possible to check the condition "password_correct" 


    For the loop: this has to be a separated action, not the same as you call in the script. 



    EDIT: @return

    add an 

    elseif eventType == eKeyReturn and keycode == 13  then 

    under the Backspace elseif in the posted script. This should handle the pressing of the Return Key. You could builtin also the script block above and just run an action part instead of setting a condition 



    Kapitán

    2346 Posts

  • #13, z marvelTuesday, 02. May 2017, 08:43 hodinky 8 years ago
    Alright, checking for the correct passwort works. smile

    But what still doesn't work is the thing with the cursor. See my approach attached.

    Also I'm still looking for a chance to check the password by pressing Enter grin

    Zabiják klíčů

    599 Posts

  • #14, z sebastianTuesday, 02. May 2017, 08:52 hodinky 8 years ago
    here is by the way a complete script of my mentioned stuff for others:


    (it starts and checks unique VS Actions/Conditions. Can be edited to check only for current acene, etc) 

    Edit: maybe the eKeyReturn could also be an eKeyDown because the keycode is still checked. 

    @marvel is this the action you call after each key pressure? 

    In this you only have to refresh the text and maybe change the object font for the moment (via lua).  No pauses, no"|"

    In ANOTHER Action you do 

    ==================
    change object font to password font
    display text "password" 
    change object font to default font
    wait 500ms
    change object font to password font
    display text "password|" 
    change object font to default font
    wait 500ms
    jump to action part #1
    ==================

    this action gets called if you open/enter the scene and stopped when close/leave it or pressing enter + password=correct

    Kapitán

    2346 Posts

  • #15, z afrlmeTuesday, 02. May 2017, 12:05 hodinky 8 years ago
    haha Thomas, you were correct earlier about conflicting values with the same names. Trying to access them in display object texts would also be an issue, but you only really need 1 value that can be used for any password puzzle anyway as you can recycle it.

    Imperátor

    7285 Posts