#TwineTuesday, Twine Tuesday

#TwineTuesday: Twine 2 Basics (Snowman)

Note: As of this writing, Snowman is the least restrictive of the default Twine Story Formats. What this means in practice, however, is that with this freedom comes the need to write your own functionality. Snowman does not come with the same common macros that both Harlowe or SugarCube do.

Table of Contents


Headers

Just like in the underlining HTML, Twine also supports all five different levels of headers. To create a header, you include the hash (“#”) in front of some selection of text and match the number with the level wanted. For example, a single hash is for <h1> element, but five hashes would be for a <h5> element.

Markup

Twine Headers

 

Result

Twine Header Result


Text Elements

To mark some selection of text to have an emphasis (italicized), be bolded, or otherwise set apart requires some special markup symbols in Twine.

Markup

Twine Text Elements

Result

Twine Markup Result


Using jQuery

While other Story Formats do give users access to the underlining jQuery that runs parts of Twine 2, Snowman allows users to directly include the <script> tag in passages, unlocking the ability to write code with jQuery in mind.

In the following example, a <div> was created and, at the conclusion of the passage, a <script> tag was included. Using a jQuery Selector, the <div> was found by its ID and its text content was set.

Markup

jQuery Markup

Result

 

jQuery Result


Creating global functions

Because Snowman allows the <script> tag in passages, the scope of functions are the passages in which they are defined. In other words, if you create a function in one passage, you cannot use it in another. However, it is possible to create more global functions by adding properties to existing global variables like document and window. This can be done in any one passage, but an easy method is to use the “Edit Story JavaScript” window within the Twine editor to have those properties created before the first passages are created.

Markup

Global Functions Markup 1

Global Markup 2

Result

Global Function Result