Howdy, Stranger!

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

SugarCube 2 Test Mode

Twine's documentation says that what Test mode does is dependent on the story format. With SugarCube 2, what is different between playing and testing? Is there debug printing anywhere (or at least a flag that I can check in my printing)? I haven't found anything in the documentation...

Comments

  • TheMadExile would be a better person to answer this question but I had a quick look at the SC2 source code and could not see anything related to Twine 2's Test / Debug mode.
  • Correction. Twine 2's documentation.

    Currently, there is no difference between Twine 2's Test and Play views in SugarCube (1 or 2). Debugging has traditionally been handled via the global SugarCube object, which you can inspect via the developer console.
  • Does the story format know when Twine is run in Test or Play view? I'm interpreting your statement to mean that SugarCube itself doesn't distinguish between Test and Play made, but the question of whether SugarCube knows its being run in Test or Play mode is still unknown to me. I'm currently debugging inside the Twine IDE without having exported to html, so having to export and then debug with dev console would be inconvenient.

    If SugarCube can somehow distinguish itself being run in Test vs Play mode, could you add a user accessible variable (ex. a story variable "test" evaluates to true when in test mode and otherwise false)?
  • edited January 2016
    mysticmuse wrote: »
    I'm currently debugging inside the Twine IDE without having exported to html
    If you are using one of the installable releases of Twine 2.0.8 then while in Test/Play mode you can use the console of the built-in developer tools which can be accessed via the CTRL-ALT-SHIFT-D key combination.

    Unfortunately this feature seems to be broken in Twine 2.0.10 when in Test/Play mode, or at least the Window 64bit release is.
  • Currently, SugarCube does not check if it's running within the Test view.

    If you wanted such right now, however, you may add something like the following to your Story JavaScript: (probably best at the very top)
    (function () {
    	window.TEST_MODE = $("tw-storydata")
    		.attr("options")
    		.splitOrEmpty(/\s+/)
    		.includes("debug");
    })();
    
    That will set the auto-global TEST_MODE to true or false depending on whether you're in the Test view or not.

    Usage is easy enough:
    <<if TEST_MODE>>/* Your debugging code. */<</if>>
    
Sign In or Register to comment.