Text Adventure?

  • #1, by CailleachSaturday, 23. April 2016, 16:25 4 years ago
    Hello! I'm very, very new at all of this. You might see some more post from me in the next few days.

    Anyway, I'm trying to build a game that has a graphical environment to it, but also let's you switch to a version of it build like an old school text adventure. Well, that's the plan, anyway. Is there some way in VS to have user be able to input text directly with their keyboard? And do commands and stuff? You know, like LOOK AT, GO THERE etc.

    Or, if it's not possible with VS, does anyone know a builder that would do what VS does but with the added text input option? Thank you so much for your help!

    Newbie

    3 Posts


  • #2, by ke4Saturday, 23. April 2016, 17:21 4 years ago
    Hi, there's a key event handler that you can use to build your function.

    There's an example script at the end fo the page
    http://wiki.visionaire-tracker.net/wiki/RegisterEventHandler

    You can either return the pressed key or listen out for keys, you could call these commands with some special keys, selecting them with arrows and enter or calling them by typing them as input.

    But there's no text objects yet, so the only way to output text as long as you need would be using object's text option or there are even other options i belive but i don't know how to use them though.

    AFRLme

    example 3 at the bottom of the page. It's a bit of a complicated example as it covers various different types of key input. The only thing you really need to do is check if it's a character & return that. If it's space bar then you insert a " " empty character & if it's delete / backspace then I guess you would remove the last character stored inside of a variable or values string field. You could probably sort it all out in 10 to 20 lines or so - I can't really say how many off the top of my head.


    the thread
    http://www.visionaire-studio.net/forum/thread/key-input-tech...

    Key Killer

    810 Posts

  • #3, by afrlmeSaturday, 23. April 2016, 19:43 4 years ago
    @ Ke4: you can now directly print text to screen using the Lua draw functions that were added to 4.2.5. There are some code examples floating about on the second page of this thread here. I haven't gotten around to testing the new draw functions out myself yet.

    I don't recommend using the non-Lua approach to key input, like in the demo that I created last year or so, that Ke4 shared the link for at the bottom of his post as it took me around 3 days to create. I made it before we had a Lua key event listener / handler event - which is much faster to use as you only need to write a few small functions, then you can create some tables to match what the person playing the game types.

    P.S: text adventures are quite complex as they use a lot of variables & if queries due to the non-linear approach of allowing the player to control the direction the story takes.

    Imperator

    6842 Posts

  • #4, by ke4Saturday, 23. April 2016, 19:52 4 years ago
    It's quite difficult for me to learn something from the example code that David posted. Would be great if some more examples would be added to wiki at some point.

    Key Killer

    810 Posts

  • #5, by CailleachSaturday, 23. April 2016, 20:08 4 years ago
    Thanks so much to you both! I'll start to try some things out with the things you said. I will quite possibly post again in a while, because I'm sure I'm going to have some problems, with my level of expertise.

    P.S: text adventures are quite complex as they use a lot of variables & if queries due to the non-linear approach of allowing the player to control the direction the story takes.


    I realise it's going to be quite a piece of work should I want to do a "real" text adventure. As it is now, I'm more looking for a proof of concept for a preliminary presentation. So I can work with some very specific commands to illustrate what I'm going to go for. So for now, if it's just an easy, simple and functional solution it doesn't need to be all-encompassing, like a real text adventure.

    Newbie

    3 Posts

  • #6, by afrlmeSaturday, 23. April 2016, 20:16 4 years ago
    You can plan your story branches out in a cloud / mind map app such as MindMaple or yEd, both of which have free versions of their apps available.

    Imperator

    6842 Posts

  • #7, by ke4Saturday, 23. April 2016, 22:07 4 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")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12


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

    Key Killer

    810 Posts

  • #8, by sebastianMonday, 25. April 2016, 08:51 4 years ago
    The hardest part would be to program a parser which recognizes all your verbs, items and variations of these words and also some additional stuff.

    Back in the days as a student at university we had to program a text adventure in java. It was ok because java is object oriented and you could easily create rooms with items and objects in it, looking around ingame to see what is around you and open doors to go to the next room.

    Here in VS i even dont really know how to start the text parser.
    How i imagine it could work is: after typing your string via the avove mentioned functions by Ke4, save the string into a lua variable, split it up in words and then go fir each word through loops which detect verbs, objects, items, etc. If they found a verb, set this as a command, if they find an object or item then as object...

    Thread Captain

    2337 Posts

  • #9, by CailleachMonday, 25. April 2016, 09:00 4 years ago
    Thank you so much, Ke4! I'm sure that'll get me started well!

    @Sebastian.204 As I said, it doesn't really need to work properly — yet, anyway, and for later I can look for another solution. For now it's fine if I can just have very specific commands and phrases that work. It doesn't need to be "detect single words" etc.

    Newbie

    3 Posts

  • #10, by afrlmeMonday, 25. April 2016, 12:37 4 years ago
    @ Sebastion.204: You could add multiple variations into a single table. Basically create a table per each scenario / interaction & then you iterate through each one. You could check in each one if a specific group of words exist in the table, if so then trigger action y.

    I agree that text adventures are hard to make, especially if you wanted the text parser to be less strict & allow the player to be able to use variations as opposed to having to enter a specified string.

    Imperator

    6842 Posts

  • #11, by MachtnixWednesday, 27. April 2016, 17:21 4 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.

    Thread Captain

    1087 Posts

Write post