Twine‐Sugarcube Cookbook - rvince452/twine-game-gen GitHub Wiki

Welcome to my cookbook of convenient code snippets and patterns

Navigation

There are many ways to navigate from one passage to another - you can use [[]] syntax or the <> macro. Here are the patterns I am following.

To create a passage link to another passage:

    [[describe passage->passage-name]]
    Example: 
    [[My house->my-main-house]]

To create a passage link to another passage AND change a variable. In this example, I increment the $hour variable before the user arrives at the new location

    [[Follow the road to the house|loc-forest-driveway][$hour += 1]]

Reasons:

  • This makes me think first of how I will describe a passage and THEN what I will name it.
  • Stick to a standard convention
  • Using a standard convention makes it easy for Copilot to understand what I am doing and that is important because it can then:
  1. Go through ALL my links and choose better descriptions (e.g. mine -> Old Copper Mine)
  2. Copilot understands the concept of forward and backward navigation, so it can go through all my links and add the reverse links. So if I have a link from passage-a to passage-b, then Copilot is smart enough to tell if the reverse link is there and if not, add it!
⚠️ **GitHub.com Fallback** ⚠️