Twine 2 plausibility



I’m not exactly a programming genius, so forgive if my questions are ill informed…

I am starting to concept out a text based adventure game, being inspired by ones like Master of Flesh and Forest & Shack. I’d rather use an engine like Twine 2 for such a project. After getting started, I’m anticipating a few issues as things get more involved.

Does anyone know if it’s possible to create a function every page runs? Ideally something I would build in another page so it doesn’t clunk down the existing page. Something that would read the variables (weight, hunger) and determine if something has happened (fat1 is false and weight > 180) [display fat1 growth text, set fat1 to true].

What I’m envisioning is something that I can simply call on at the end of every page to check variables and display flavor text, when conditions are met. I’d rather not build this big function I have to paste on every single page. Thoughts?


Moved to the Project Help/Game Engines category as this is a question about the twine engine and not general game design.


Specific solutions will depend a bit on which format you end up using within Twine 2. I have some experience with the Harlow story format.

You can find the full documentation here:

Of particular note would be the “display” macro, which lets you display the contents of a specified passage on demand. This can be used like a primitive function call (but without any real “return” values. It’s a bit clunky in that you’re still likely to use global variables), but can be called/displayed at end of your page as you mentioned.
Example: (display: "Cellar") prints the contents of the passage named “Cellar”.

There are also special “header” and “footer” tags that can be applied to special-purpose passages that you want to run with every other passage in your story. This is useful for a blanket set of macros to be run each time.