Is there an easy way to loop text in Inform 7?

0 votes
97 views
asked Sep 3 in Authoring by anonymous

I feel like there must be some simple method and I'm missing it (as usual). What I want is something like this:

Grazing is an action applying to nothing.
Understand "graze" as grazing.
Instead of grazing, say "You eat an onion." then "You nibble a carrot." then "You consume a turnip." then "You chomp a bagel."

I know the programming syntax would look nothing like that, but I wrote it like that to convey the idea. After "You chomp a bagel." is displayed, then it should loop back and say "You eat an onion." and continue to loop indefinitely whenever the player uses the "graze" command. In that specific order: onion, carrot, turnip, bagel. Over and over.

1 Answer

+2 votes
answered Sep 3 by bg (692 points)

For that you use "[one of]," "[or]," and "[cycling]."

From ยง5.7. Text with random alternatives, here's an example:

say "The pundits discuss [one of]the weather[or]world events[or]celebrity gossip[cycling]."
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...