Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I correctly include SugarCube2.x Javascript Macros in Twee2?

edited May 2016 in Help! with 2.0
So I'm trying to convert the game I've been making in Twine2/SugarCube2.6.1 into Twee2 0.4.2 format and compile with Sugarcube 2.6.1. I figured out how to correctly install and compile with the 2.x Sugarcube format, and my game is mostly working correctly. I just have one issue...

I want to use Leon's combined replace link macro set for <<insertlink>> and <<replacelink>>, but whenever I compile using Twee2 and try to open my .html file, I get the following error:

"Error[tw-user-script-0]: Unexpected token &."

If I cut out the javascript related to the replace link macro set from my [script] passage, I have no errors or warnings except for my <<insertlink>> tags failing (obviously, since the code to run them isn't there).

Anyone have some ideas on how to make the macros play nice with the Twee2 generated file?

Comments

  • This is the first few lines of the javascript it seems to be having trouble with:

    /*! <<replacelink>> macro set for SugarCube 2.x */
    !function(){"use strict";function showVer(n,notrans){n&&(n.innerHTML="",new Wikifier(n,n.tweecode),n.setAttribute("data-enabled","true"),n.style.display="inline",n.classList.remove("revision-span-out"),notrans||(n.classList.add("revision-span-in"),n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(function(){n.classList.remove("revision-span-in"),n=null},20)))}function hideVer(n,notrans){n&&(n.setAttribute("data-enabled","false"),n.classList.remove("revision-span-in"),n.timeout&&clearTimeout(n.timeout),notrans?(n.style.display="none",n.innerHTML="",n=null):(n.classList.add("revision-span-out"),n.timeout=setTimeout(function(){"false"===n.getAttribute("data-enabled")&&(n.classList.remove("revision-span-out"),n.style.display="none",n.innerHTML=""),n=null},1e3)))}function tagcontents(b,starttags,desttags,endtags,k){function tagfound(i,e,endtag){for(var j=0;j
  • edited May 2016
    That would be because Twee2 is erroneously encoding the contents of script and stylesheet passages. It's also erroneously not encoding various other things that it should be—the story title, as one example.

    I can only conclude that any testing of the correctness of Twee2's output was minimal, at best.
  • Is there an alternative that will let me work from Notepad++ with the technologies I want to use right now? I love the syntax highlighting and having my game divided up into a folder structure that makes sense to me, but copy-pasting back and forth from Twine2 is really tedious and will likely smack me with copy/paste bugs eventually.

    Is Twine 1.x + Twee better, and would my SugarCube code all be compatible?
  • Lexirad wrote: »
    Is there an alternative that will let me work from Notepad++ with the technologies I want to use right now?
    Alternatives. If you want to use SugarCube v2 with a Twee-style workflow, I'd suggest either using Twee—IIRC, you must also install Twine v1.4—or my own TweeGo—which does not come with story formats, however.

    The easiest thing would probably be to download TweeGo (v0.99.0) and the version of SugarCube v2 which works with it. After you've placed the TweeGo executable somewhere, make a targets directory within the same directory, then place the SugarCube v2 directory from the archive within that targets directory. In other words, it should look something like the following:
    some_directory/
    	targets/
    		sugarcube-2/
    			LICENSE
    			header.html
    			sugarcube-2.py
    	tweego
    
    From there, simply typing tweego at your command line will yield help on how to use it—as long as you're in that directory or it's in your path variable.

    Lexirad wrote: »
    Is Twine 1.x + Twee better, and would my SugarCube code all be compatible?
    The compiler you're using has little bearing—none really—on your code, that's the domain of the story format itself. So, yes, your SugarCube v2 code will be compatible.
  • That's fantastic. I'll go explore those options and figure out which way I like best. Thanks for the help!
  • TweeGo worked perfectly for what I want to do! Awesome. Thanks again.
Sign In or Register to comment.