beanz Magazine

Inform 7 Interactive Stories

Marcin Wichary on Flickr

Rediscover the fun of some of the first video games with Inform 7!

You are in your room, which is possibly inside a space station. You can't remember.
You can see a table (on which are a magazine and the spinning wheel (in which is the hamster)) here.
>examine hamster
The hamster squeaks at you happily.
>take hamster
I don't suppose the hamster would care for that.
>take magazine
>examine magazine
It's a copy of the February 2021 issue of Beanz! It seems to have an issue on interactive fiction. You read on...

So the above is an example of the output of the programming language we’re going to be talking about in this issue: Inform 7. Inform 7 is different than most languages for two big reasons. The first is that it doesn’t just compile into your typical programs but rather an Inform 7 program creates an entire explorable world in a text adventure format. The second is that Inform 7 programs don’t even look like normal programs but look more like describing things in English.
For example, the code that led to the above is this:

The Bedroom is a room. "You are in your room, which is possibly inside a space station. You can't remember." There is a table in The Bedroom. On the table is a magazine. On the table is a transparent container called the spinning wheel. There is an animal called the hamster.
The description of the hamster is "The hamster squeaks at you happily." The hamster is in the spinning wheel. The description of the magazine is "It's a copy of the February 2021 issue of Beanz!
It seems to have an issue on interactive fiction. You read on...".

Just from this code Inform is able to build an entire world you can interact with. It even understands, for example, from the fact that the hamster is an animal that you can’t just easily pick it up and put it in your pocket! A magazine, on the other hand, is an object which you should be able to hold.

Interactive fiction like this example has a long and important history in video games. These were, really, the very first games going all the way back to the 1970s with games like Adventure or Zork. In fact, Inform 7 is named the way it is because it’s a modern version of the Inform system that was used to make interactive fiction games 40 years ago.
These are games where you type commands in order to take actions in the game: move around between rooms, use objects, eat food, pet dogs!

Let’s take that last one as a jumping off point. So if, given our example already, we wanted to try petting the hamster we’d get the message

>pet the hamster
That's not a verb I recognise.

But we can add verbs to Inform 7! Here’s the code to add petting animals into your game, a rule to make sure you don’t try and pet inanimate objects, and a special exception if you try to pet the scorpion we’ve also added to our story.

Petting is an action applying to one visible thing. Understand "pet [something]" as petting.
Check petting:
if the noun is not an animal, say "You can't pet an inanimate object! That's weird!"
Carry out petting:
say "You pet [the noun]. They seem happy!"
Instead of petting the scorpion:
say "It's a magic scorpion and it doesn't like touch! It stings you so hard!";
end the story.

So, yes, we’ve now shown that you can ensure that your game will get the approval of the twitter account @CanYouPetTheDog, which is probably the most important bar you can ever meet.

Of course there’s so much more you can actually do in Inform 7. There’s systems for vehicles, the passage of time, keeping a score for the player, conversations with characters who remember what you’ve said, and all sorts of things that let you make really rich and powerful stories. All of that done in a true programming language like nothing else you’ve ever learned!

Learn More

Inform 7 website

interactive fiction archive

Beginner’s Guide to Inform 7

Writing Interactive Fiction

Inform 6 website

Introduction to Inform 7

Interactive Fiction Competition


A Brief History of Zork


Top Interactive fiction games for kids

Interactive fiction in the classroom

Also In The February 2021 Issue

Low code and no code software makes it possible for non-technical people to create software.

Learn how to program through a series of fun and dynamic activities in Patricia Foster's book!

Learn how to make a contact microphone for picking up the vibrations in your sonic experiments!

If you can't go out to an art museum, then bring the art museum to you using Sketchup!

Find out how people are saving classic games through restoration and archiving!

Find out what a giant wooden horse and your cyber security have in common!

Learn about some of the ways people use to communicate before the internet!

An interview with Solderpunk about the inspiration and the creation of Gemini!

Forks are used in software development to describe how projects and software work.

Computer science unplugged teaches how computers and computer science works, without the use of computers.

Links from the bottom of all the February 2021 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about science and technology for February 2021.