Creating a Password

  • #1, by monicaamorosTuesday, 13. June 2017, 18:09 8 years ago
    Hello
    I'm a beginner in Visionaire Studio. I've created a simple Room Escape game and as the final obstacle I want to do a password code where you have to write 4 numbers. How can I do that?
    Any help would be really helpful as this is part of a university project.

    Newbie

    3 Posts


  • #2, by AkcayKaraazmakTuesday, 13. June 2017, 18:17 8 years ago
    Player should write them via keyboard or clicking the numbers on a numpad on a scene object?

    Great Poster

    440 Posts

  • #3, by sebastianTuesday, 13. June 2017, 18:37 8 years ago
    I found a topic which deals with the same  question (password is typed by keyboard from the player):

    Thread Captain

    2346 Posts

  • #4, by ke4Tuesday, 13. June 2017, 18:40 8 years ago
    Via Lua script - a keyboard input:

    For visible input:
    You are gonna need to create a value where you will be storing the data.
    And you will also need to create and "Called by other action" action which will be having display object text action part to refresh the text.

    function keyboardHandler(eventType, character, keycode, modifiers)
    
     if eventType==eEvtKeyTextInput then
    
      Values["password"].String = Values["password"].String .. character
    
     elseif eventType == eEvtKeyDown and keycode == 8 then
    
      Values["password"].String = string.sub(Values["password"].String, 1, -2)
    
     end
    
     startAction("Scenes[yourScene].SceneActions[refresh]")
    
     return false
    
    end
    
    
    
    registerEventHandler("keyEvent", "keyboardHandler")

    But there's a lot of options. You can also display just **** instead of the input. Or you can set up some screen with numbers/letters and do it just with mouse clicking.

    In that case you can just make an object for each number/letter and add the number to a string. Then compare the string to your password.

     Values["password"].String = Values["password"].String .. "1"

    Key Killer

    810 Posts