Welcome Robert.
First you can see many possibilities and examples of how to use them at https://www.motoslave.net/sugarcube/2/docs/.
For what it’s worth I think there’s four most important things to understand:
The easiest way to send the reader to another passage is with a
[[Flavour text|Link to the next page]]
Example:
What do you want to do?
[[You charge head first to the big burly hobgoblin.|Fight the Hobgoblin]]
[[Better to bribe your way out of this mess.|Bribe the Hobgoblin]]
Note that Twine will automatically create the Fight the Hobgoblin and Bribe the Hobgoblin passages.
Of course there are more about links between passages, but these are the basics.
The second important thing is variables. They store information. Numeric variables can easily be modified. Variables are declared with a <<set>>
macro. https://www.motoslave.net/sugarcube/2/docs/#macros-macro-set
Examples:
<<set $Character_melee to 4>>
<<set $Character_HP to -=5>>
The first line creates (or overwrites) the variable $Character_melee and gives it the value 4. The second one substract five from current HP total. Variables can be caught at any times after they are set.
It is possible to set a temporary variables, temporary variables starts with an ‘_’, example _HPloss is a temporary variable, while $HPloss isn’t (it’s called a story variable, as story variables follow the reader through the story, temporary disappear as soon as the passage is over).
The <<if>>
macro https://www.motoslave.net/sugarcube/2/docs/#macros-macro-if is probably the most powerful tool of all. It allows to determine effects based on variables and/or random results. The macro needs a logical test and a <</if>>
closure. It allows for alternate possibilities with <<elseif>>
, and <<else>>
, the former calls for another logical test, the later happens if no logical test returns a true.
<<if $Character_sexe is "female">>The blond paladin looks at you as a defenseless creature it's he's duty to keep out of harm. Though you can't shake the impression you could drown yourself in his hazel eyes you fell safer than a few minutes ago.
<<else>>The paladin smiles at you. Your plea seems to have a considerable appeal to him. Soon he draws his sword, points it to the sky, and vows to help you fulfill your destiny for as long as you need his help.<</if>>
How to use random? There’s two main ways to use random. If all outcomes should have the same chance to happen you’ll like to use either()
https://www.motoslave.net/sugarcube/2/docs/#functions-function-either.
<<set _round_result to either("Win","Loss")>>
<<if _round_result is "Win">>You thrust your sword deep in the flesh of the Hobgoblin.<<set $Hobgoblin_HP -=5>>
<<else>>The Hobgoblin wields his mortal hammer too powerfully for you to stop it. You're hit, you're bruised, and you start to regret to have ever leaved your comfortable house.<<set $Character_HP -=3>>
<</if>>
However, you might sometimes want to have outcomes more likely than others. Then you’ll probably like the random()
fonction SugarCube v2 Documentation.
Example;
<<set _combined_melee to $Hobgoblin_melee + $Character_melee>>
<<set _round_result to random(1,_combined_melee)>>
<<if _round_result lte $Character_melee>>You thrust your sword deep in the flesh of the Hobgoblin.<<set $Hobgoblin_HP -=5>>
<<else>>The Hobgoblin wields his mortal hammer too powerfully for you to stop it. You're hit, you're bruised, and you start to regret to have ever lived your comfortable house.<<set $Character_HP -=3>><</if>>
In this second case, the more skilled the character, the more chances he’ll have to hit the Hobgoblin.
Honestly, there’s the basics. When you’re comfortable with these you can play with other things.