Howdy, Stranger!

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

How to interact with Twine objects in the javascript console

I'm using SugarCube and the Twine 1.3 beta. What context do I need to prefix in the javascript console to inspect or interact with header functions and data?

In case the question isn't clear: If I want to look at a function in global scope, I can just type the name of the function, or window.FUNCTION. But most of the code from the headers is within a different namespace, and I presume that if I can simply prefix the name of that context to the name of the function I'm interested in, I should be able to inspect it. But what is it?

Comments

  • Caveat: Do not write production code using this (yes, it's happened before).  It is only for debugging/inspection.  Additionally, SugarCube's full scope is not exported.

    SugarCube creates a limited export on the window.SugarCube property.  The currently available properties are:
    • version
    • runtime
    • has
    • browser
    • config
    • setup
    • storage
    • session
    • macros
    • tale
    • state
    • Wikifier
    • Util
    • History
    • SaveSystem
    • UISystem
    As an example, to inspect the variable story of the currently active state you'd type this into the console:

    SugarCube.state.active.variables
  • Perfect, and also perfectly nice. Thank you!
Sign In or Register to comment.