[Twine game] Armies of Tor
Here is the link:
https://www.dropbox.com/s/y7v530s589kh1nj/Armies%20of%20Tor.html?dl=0
hope you enjoy :)
https://www.dropbox.com/s/y7v530s589kh1nj/Armies%20of%20Tor.html?dl=0
hope you enjoy :)
Comments
Have a great day :)
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.
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? :)
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":
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:
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:
"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:
And query them to determine which links to display:
and combine all of it:
So uhhh, it's not so much a Twine parser as it is a parser for the subset of Twine functionality we use.
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!
@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 ;)