A story within a story

I am trying to write a game in which the player reaches a kind of hub where other stories unravel.

To give some specific example, think of a story in which the player eventually ends up in a library. Each time the player picks up a book they get transported into the world of the book and must finish that adventure in order to get back to the library. At some point, the player leaves the library and the “main” game continues.

Each book can have its own rooms, characters and rules.
When a book story ends, the player gets back to the library and nothing has changed.

Going through the docs, I think my best bet is Flashbacks: http://inform7.com/book/RB_4_5.html.
I would love to hear some ideas about how you would implement something like this. Foremost I would like some hints about how you would organice the source code.
Any extensions, examples, etc are apreciated!

I’m also trying something like this (although not a library). I just have rooms for each different section (like your different books) that connect to each other but not to the hub or other sections, and when the player does the right thing in the hub, I have “move the player to X location” so they can play that section. When they finish that one off and trigger the end of that section, I just did “move player to hub”.

This has seemed pretty easy to me, and pretty easy to organize, but I’m very curious if there’s another, better way.

You might want to check out The Library from this year’s IFComp. It sounds very similar to what you want to do.


Also look at the Viewpoint examples: 5.6. Viewpoint

If you define separate player characters in separate areas of the game, you can just write

now the player is Zaphod;
1 Like

Scenes seem like the most obvious way to organize having sub-games in which different rules apply.

Having multiple disconnected locations takes no extra effort: I7 doesn’t object to creating rooms that way.


It seems quite similar, but also more complex because of the presence of the parser. My point and click (and drag) interface makes the implementation easier.
The link of “the library”: The Interactive Fiction Competition

1 Like

I have done this a bunch of times. Here’s an example adapted from how I did it in The Ascent of the Gothic Tower:

Hallway is a room.

The player is in Hallway.

The player carries the tome.

Nested Narrative Completed is initially false.

Instead of examining the tome:
	if Nested Narrative Completed is false: [This sort of clause is useful if you don't want the player to be able to complicate things by playing your nested thingy over again, but it's not necessary.]
		start the nested section;
		say "You already read that tome. No need to go through all that again."

To start the nested section:
	say "First there's some transitional text...[paragraph break][bracket]Press any key to continue...[close bracket][paragraph break]";
	wait for any key;
	now the story tense is past tense;
	now the story viewpoint is first person singular;
	now the player is Pat;
	try looking.

Nested Story Area is a region.

Garden is a room in Nested Story Area.

Pat is a person in Garden.

It’s fun to change the story tense and/or story viewpoint for these nested narrative sections. In Gothic Tower it’s first person past tense because the nested story is a diary.

When you go back to the frame narrative, you have to restore the player to their initial “yourself” persona. And if you changed the story tense or viewpoint, you need to change those back. And if you’re using some variable to track something from the framed story, then, you’d better do that, too:

Instead of attacking the caelwyrm:
	say "Without wasting another moment, I drove my spear into the caelwyrm's heart, thus undoing its curse. Here my story ends.[paragraph break][bracket]Press any key to continue...[close bracket][paragraph break]";
	wait for any key;
	now the player is yourself;
	now the story viewpoint is second person singular;
	now the story tense is present tense;
	now Nested Narrative Completed is true;
	try looking;

Now, in every project I start out with a bunch of custom default message replacements and little systems adjustments. I call this the “Boring” section. Below that, I start talking about the actual contents of the game, rooms and objects and stuff. Something like this:

"New Girl" by Ryan Veeder

Volume 1 - Boring

Instead of attacking something, say "You're not supposed to attack stuff in this game."

[And so on for smelling, squeezing, climbing...]

Volume 2 - Scenario

Loft is a room. Description of Loft is...

I organized the Gothic Tower source code by implementing everything in the main narrative first, and then implementing the framed section as basically its own little game.

Volume 1 - The Regular World

Book 1 - Boring stuff in the Regular World

Instead of attacking something:
	say "You're not supposed to attack things in this part of the game."

Book 2 - Scenario of the Regular World

Hallway is a room.

Volume 2 - Nested Part

Nested Story Area is a region.

Book 1 - Boring stuff in Nested Part

Instead of attacking something while the location is in Nested Story Area:
	say "I did not attack [the noun], for my sole charge was to rid this world of the hated caelwyrm."

Book 2 - Scenario in Nested Part

Garden is a room in Nested Story Area.

I probably copied the entire “Boring” section from the main part and added a “while the location is in…” to each rule before changing its text to match the tense/viewpoint/tone of the nested section.

The condition can be ...while the location is in {the region where you put all the rooms for the nested section} or ...while the player is {the person you designate as the PC of the nested section} or ...during {the scene that represents the nested section}. (I never use scenes, so I can’t really speak to that.) The options are all equivalent… unless you do something complicated, like letting the protagonist of a book leap out into the real world.

So, for the “most simple” version of this idea, you don’t really need any fancy extensions. You basically just want to write an additional game for your nested story, and make sure that its rules only apply within that sub-game. And then you need rules for entering and leaving the story.

If the conditions on your rules are suitably specific, you can have as many sub-games as you want, nested any way you want, without all that much fuss.


Concur and agree. Seems a plot tailored for one of the major strength of I7.

Best regards from Italy,
dott. Piergiorgio.

Love this approach and organization!
Definitely going with your way.
The rule ...during {the scene} seems like the most clean to me.

The html player for The Library is really weird, is that just inform7?.
Is the source code for these stories available somewhere?

It’s not Inform7. It’s just JavaScript. In my post I said that it was simpler to develop The Library because there was no parser, but the post of Veeder opens new possibilities. Maybe one day I’ll try to develop a version of The Library in Inform7.