Creating a Password

  • #1, z monicaamorosTuesday, 13. June 2017, 18:09 hodinky 7 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.

    Bažant

    3 Posts


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

    Čestný člen

    440 Posts

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

    Kapitán

    2346 Posts

  • #4, z ke4Tuesday, 13. June 2017, 18:40 hodinky 7 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"

    Zabiják klíčů

    810 Posts