How to write pure squiffy functions

You might need repeating code (like inventory or known facts). While putting code in [[]] might work, it also means you're going to get the info at every step, including short combat questions. You don't want to be asked if you'll fight or run and be given your full inventory, too.

Here is an example of how to write a section that works like a function. Simply make sure that retAddr contains the name of the next section so the function knows where to go when done. For inventory, you might even loop back to where you called it from. It works.

So here's the example:

[[first section]]:

You are in the first section.

@set retAddr=continuing section

[[function]]

[[continuing section]]:

The play continues...

[[function]]:

IN FUNCTION CODE

[[Return to game]]({retAddr})

Just a trick I picked up.


BTW, you could write your function to have multiple code returns. For example, if you write a combat function, you could have @retWinAddr and @retLoseAddr, so that you automatically end up in the correct place following combat.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums