[Twine game] Armies of Tor

edited in Projects

Comments

  • I don't think you shared this correctly because it wants me to download it instead of play online...
  • @Fengol, I have a problem with running JavaScript in Dropbox and the only option it gave me thus, was to share the link so people could download it.
    Have a great day :)
  • edited
    So I found out there's a difference between a Shared link and a Public link on Dropbox; which sucks for new developers hoping to use Dropbox to grant access to their games.

    There's a site called TwineHub but they're currently not accepting new games while they move servers.

    In the meantime, here is @Jurgen's game publicly shared for you to play.
    Thanked by 1Jurgen
  • Like the art, and would like more options for more outcomes?
  • @Boysano, thanks, I'll work that into following projects :)
  • edited
    @Jurgen, Very very cool - I just happen to be exploring Twine integration with Unity as we speak...

    Twine's ease of use to create branching stories is amazing and intuitive. I am currently prototyping a Star Control like conversation mechanism where Twine as an external tool plays a central role in constructing the story. Also to check out the new Unity UI features to facilitate the conversation.

    Now the trick is how to parse Twine in Unity, grrrrr. Not as easy as I thought, however...
    our very own local devs of The Maker's Eden seem to have the Twine parsing down... I need to bribe them to find out how do they do that? :)
  • @konman: Just ask @rustybroomhandle, he made their plugin available AFAIK :)
  • @konman, glad you liked it! I saw the youtube parsing video, very interesting. That's something my brother would also be interested in, thanx. Enjoy creating :)
  • edited
    Hullo, you rang?

    Yarrr, our plugin is not released because the code is utter crap, and I likely won't fix it up till after TME act 3 is done because right now it works ok for me, but the principle of how it works is sound, so I'll explain.

    Technically it's not a full Twine parser we use, but a Twee source parser. (Twine->Export Source) And it's just a very basic implementation with some equally specific requirements and limitations.

    The Twee source code looks like this (two cards below, titled "fixed' and "handsome":

    :: fixed
    other|Oh, I k-know, but I just don't feel comfortable looking like... them any more, you know?
    img|gartley3
    
    [[I understand.|understand]]
    [[I do. Hey, I bet you're a handsome hunk o' chrome under there|handsome]]
    
    :: handsome
    other|That's very - very - nnnnn - nniiiii11111000101000101010011...
    img|gartley5
    
    [[You okay there, G?|ok]]


    I load the text into Unity as a TextAsset, and then parse it into a json object. "Parsing" is basically a matter of splitting the text on ":: " and then for each of those array items, splitting them into the bits I need. In my case it looks like this-ish:

    [{
    	"node": "fixed",
    	"image": "gartley3",
    	"text": "Oh, I k-know, but I just don't feel comfortable looking like... them any more, you know?",
    	"responses": "[[I understand.|understand]][[I do. Hey, I bet you're a handsome hunk o' chrome under there|handsome]]"
    },{
    	"node": "handsome",
    	"image": "gartley5",
    	"text": "That's very - very - nnnnn - nniiiii11111000101000101010011...",
    	"responses": "[[You okay there, G?|ok]]"
    }]


    I parse each line of a card and see what it starts with, ie "other|" or "img|" or ":: " for the node name, and then derive from that where in my json to put the text.

    I have a function lo load a card, which I can do by node name.

    The links are delimited with [ [Text here|targetnode] ] and I parse those when I load a card for display on screen. I don't even use regexes for it, I just remove all the "[ [" bits and then split on "] ]" (no spaces). These I make into buttons that call the function that loads up cards.

    Limitations:
    - Every line's purpose needs to be declared to the parser by having "something|" at the start of the line
    - Doesn't do hyperlinks in the middle of text - they have to be on separate lines.

    Improvements:
    In our implementation, we can supply special commands to links by embedding them in the code, like this:

    [[Take the apple<exec,TakeApple>|apple]]


    "exec" is the most often used one, it'll SendMessage("TakeApple") to an Actions script we have that executes Unity functions.

    We can also set flags this way:

    [[Take the apple<setTrue,HasApple>|apple]]


    And query them to determine which links to display:

    [[Take the apple<ifFalse,HasApple,setTrue,HasApple>|apple]]


    and combine all of it:

    [[Take the apple<ifFalse,HasApple,setTrue,HasApple,exec,BendInPocket>|apple]]


    So uhhh, it's not so much a Twine parser as it is a parser for the subset of Twine functionality we use.
    Thanked by 1konman
  • The above is the conversation format, but we also have a slightly different one for hotspots. These cards look like this:

    :: dummy
    description|Dummy text used as a placeholder.
    mouseover|Hotspot placeholder
    
    [[Wax on<setTrue,wax>|dummy2]]
    [[Wax off<setFalse,wax>|dummy3]]


    Got code that scans a scene for objects tagged "HotSpot" and then pulls a Twee node from the json array that matches its name, ie "dummy" and adds scripts for "mouseover" text and "click" that loads the corresponding card. It's mostly the same as the above mentioned functionality.

    The main part of my code I want to change is that I had bad luck with dynamically sized data structures, so I gave up and just made a ginormo-huge empty array of fixed size that I plonk my data into. ;) Wha-eh-va!
  • @Jurgen Sorry if I slighly highjacked your thread with the tech stuff here ;-P

    @rustybroomhandle Wow, thank you very much for sharing!!

    I figured out after watching your YouTube video that the me| and other| bits were not part of twine, but are custom tokens to display responses from 2 parties in a passage.

    The <exec,TakeApple> bit is ingenious. I was wondering how one could let the chat drive actual events.

    Also the dumping into json... I was simply using a POCO class to store it in memory, but json will work nicely here.

    Awesome thanks a mil, this has shortened the curve for me by a large margin ;)
  • I'm a front-end web guy by profession, so I tend to fall back to things I'm comfortable with, i.e. js/json. Just picked up Unreal Engine 4, so now I need to dig up C++ from the cobweb riddled part of my memory. :P
Sign In or Register to comment.