Sadako: a new hypertext adventure engine

I’ve spent the last few months working on a project that I’d like to share with the public. My goal was to create a scripting language that merged my favorite things about Twine and my favorite things about Ink into one package, and I feel like I’ve succeeded.

Sadako is written entirely in ECMAScript 5 compliant JavaScript and is meant to be included in an HTML page. However, I left the text output functions exposed so that they can be easily overridden with functions targeting a different UI, if anyone wants to include it in an Electron app or something similar.

You can see a demo game of it here: http://tayruh.thanatos.feralhosting.com/gamebook/

Some other links:

Here’s a snippet of what the script syntax looks like:

## remote
	It's the remote for the television. Erin is looking for this.
	
	+ [Use]
		~~ if ($.bookmark === "erin.remote")
			[:&
				sadako.closeDialog(true);
				game.move(null, "remote");
			:]
			You hand the remote to Erin.
			"Thanks, $:name!"
			She points it at the TV and turns the volume up a couple notches. "Ah. Much better."
			+++ {gave} [Back]
				>> #living_room
		~~ else
			You can't find a use for the remote here.
			
			[:& sadako.doLink("#inventory") @: Back:] ~:choice
			<< END
	+ [Back]., >> #inventory

One of the big features of Sadako is that you can either compile the source to a JS file to be included into your page, or you can write the script directly into an HTML page. The following is a fully functioning (albeit incredibly short) game.

<html>
    <head>
        <style type="text/css">
            .choice { 
                cursor: pointer;
                color: orange;
            }
        </style>
    </head>
    <body>
        <div id="output"></div>
        <textarea id="source" style="display:none">
            ## demo
                Hello world
                + Choice one[] was chosen.
                    Maybe try choice two next time?
                + Choice two[] was chosen.
                    Maybe try choice one next time?
                - The End
        </textarea>
    </body>
    <script src="sadako.js" type="text/javascript"></script>
    <script src="kayako.js" type="text/javascript"></script>
	<script type="text/javascript">
        sadako.init();
        sadako.startGame("demo");
    </script>
</html>

Anyway, I guess that’s it. Hopefully you guys will check it out and let me know what you think.

Edit: Rewrote the description and changed the title because I don’t think that I presented the information very well the first time around.

4 Likes

I was unsure whether to keep updating this thread as I add features, but I figured that it’d make sense if I added big ones that might be of interest. shrug

After realizing how useful scenes are for Inform and TADS, I decided to add them to Sadako. And so I did. As far as I’m aware, I managed to emulate their functionality almost exactly.

To be honest, it comes at a good time because I was trying to figure out how to prevent the game I’m working on from turning into spaghetti code. This will solve a lot of those problems. :smile:

Anyway, I updated the demo code in the first post (and also the demo itself, but the changes aren’t visible), and added the info on how to use it to the reference. There’s a direct link to the section right here.