#TwineTuesday, Twine Tuesday

#TwineTuesday: Twine 2 Basics (Harlowe)

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 be emphasis (italicized), bolded, or otherwise set apart requires some special markup symbols in Twine.

Markup

Twine Text Elements

Result

Twine Markup Result


Bulleted and Numbered Items

To have Twine produce bulleted or numbered items, some selection of text needs to have asterisks and then a space (“* “) before them for top-level and two asterisks (“**”) for indented items. For numbered items, use a zero and then period (“0.”) for top-level and a zero, period, second zero, and second period (“0.0.”) for indented items.

Markup

Twine Bulleted Items

Result

Twine Bulleted Result


 

Using (set:) macro

The Set Macro is one of the most powerful and common macros found in Twine. In order to save (“set”) some value, the Set Macro is used.

Markup

Twine Set Macro

Result

Set Macro Usage


 

Combining (set:) and (if:) macros

In most cases of using variables in Twine, you will want to first “set” some value and then, at some later point, conditionally act from testing the value. In Twine, you can combine the Set Macro with an If Macro to test is some condition is “true.” For example, if a value “is” the same as another or if some other comparison results in a “true” statement.

Markup

Twine Set and If Macros

Result

Twine If Macro usage


 

Using (either:) and (random:) macros

In some cases, you will want Twine to choose some value for you. If you want Twine to pick a single value between some fixed, existing set, the Either Macro will work. For those times when you want Twine to pick a random value between two positive numbers, the Random Macro will work.

Markup

Twine Either and Random Macros

Result

Twine Either and Random Macro Usage


 

Using a dataset

In Twine, a dataset is not unlike a bag: you can put different things in it, but to test if something is in the dataset, you need to see if it “contains” something or if some data “is in” it.

Markup

Twine Dataset Macro

Result

Twine Dataset Usage


 

Using (datamap:)

A datamap in Twine is a structure with key-value pairings. You use a “key” to lookup some “value” in the map.

Markup

Twine Datamap

Result

Twine Datamap Result


 

Using (print:)

While variables can be used directly in any passage, sometimes you may want Twine to dynamically display some content that contains other markup. For those cases, you can use the Print Macro to have Twine “print” the result of some combination of macro calls or JavaScript.

Markup

Twine Print Macro

Result

Twine Print Result