Interactive Fiction _13 – Loops

Most scenarios in interactive fiction will not require a loop.  But for completion and the possible situation where you might need a loop I have included it here.  I used the Inform 7 syntax document to concoct these examples:



The dog park is a room.
A stick is in the dog park.

After dropping stick:
    repeat with index running from 1 to 10
        say “Woof.”;
    end repeat.

There is syntax for a while loop, but I haven’t found a way to use it better than the use of an every turn rule ….

Every Turn:
If player carries the one ring:
say “The ring is such a burden to bear!”.