Text Adventure?

  • #10, z MachtnixWednesday, 27. April 2016, 17:21 hodinky 9 years ago
    You can use "twine" (twinery.org) for nonlinear text games, but without text input (only case query). I think you must learn some "Harlowe" programming to add text input, but I haven't tested it yet.

    Kapitán

    1097 Posts


  • #11, z sebastianSunday, 01. May 2016, 20:44 hodinky 9 years ago
    Well i guess the simplest way to get basic input would be something like this, you need to create a value to store the data in there.

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


    When refresh action only display the object text which includes
    <vs=valueName>
    


    This script works great. I experienced a funny behaviour when the string contains umlauts like ä ö ü and stuff.
    When pressing backspace and this should erase only the umlaut, the complete string gets removed...

    Example:
    Type "lkada sdaü asdkjh".
    Press Backspace.
    Continue pressing backspace.
    When reaching the ü all characters before also get removed.

    funny grin

    Kapitán

    2346 Posts