0 votes
by (350 points)
Hi.  I was wondering if anyone could clarify (or add links to clarify) the "Setup object" in sugarcube.  It's mentioned in both versions 2 and 1 in the manual under "special names".  However, neither manual goes into sufficient depth that I can work out how to access or use it.

Thanks for any help that you can provide.

1 Answer

+1 vote
by (63.1k points)
selected by
Best answer

It's just an empty object for authors to use as a namespace so they can avoid any naming conflicts with SugarCube or with the browser. It's generally a better place to store functions and data than the global scope. 

There's no real docs on how to use it because there's really not much more to it than that. For completeness, though, to use it in Story JavaScript: 

setup.myFunction = function (message) {

In TwineScript: 

<<set setup.myVariable to 10>>


by (350 points)
Ah, I see.  It is pretty straightforward, but your examples make it crystal clear.  Thank you very much!