One of the things I've thought about doing is saving information between Twine games. The built in Twine <<remember>> macro allows you to save a variable in a cookie, which can then be read from multiple stories. This is exactly what I needed, but the problem is that it was not working properly in Twine 1.3.5. This was incredibly frustrating to me, and nearly made me want to give up on Twine. After some digging I found a story format update that fixes the macro, and saving cookies works! I am considering using this to break up Midnight Room into separate games.
Another thing that came to mind was the ability to change the color of passages with a macro. I figured this would be simple enough to do with a macro, so I went about looking for info on how to write them. I don't have a lot of experience coding with Javascript for the web so a lot of the technical stuff is new to me. Luckily I found a great blog post on creating your own macros. I was able to mess around with things to the point of getting the page background color to change with a macro like this <<backgroundColor "#fff">>. Changing text color was stumping me, so I dug further and found another useful post with something similar to what I was after. My final macro looks like this <<recolor "#ff0" "#0fe">>. Here is the little macro I put together.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
version.extensions['recolorMacro'] = { | |
major:1, minor:0, revision:0 | |
}; | |
macros['recolor'] = { | |
handler: function(place, macroName, params, parser) { | |
if(params.length > 0) { | |
this.back = params[0]; | |
this.texxt = params[1]; | |
} | |
document.getElementsByTagName("body")[0].style.backgroundColor=this.back; | |
document.getElementById("passages").style.color=this.texxt; | |
}, | |
init: function() { | |
this.back = "#000"; | |
this.texxt = "#fff"; | |
}, | |
}; | |
} catch(e) { | |
throwError(place,"recolor Setup Error: "+e.message); | |
} |
Twine is great not so much because of what it does, which is pretty cool, but more so because of the awesome developers and community (although small) around it.
No comments:
Post a Comment