top expert

a biting cat website

Let’s Make IF #4: let’s make a scene.

Last time, on let’s make IF…

Here we go again! Here’s how we left things yesterday:

  • I need to come up with a strategy for room and item descriptions that might change more than once over the course of the story.
  • I need to start writing!

Just to get it out of the way.

Since we have zero text in this game so far, let’s at least write an opening splash. I have some things I’d like to try with text in this game:

  • First-person narration.
  • Past tense.

There’s some first-person text in Repeat the Ending, so I have some experience with that. However, I suspect that past tense is going to be hard. The recent IF Comp winner Dr. Ludwig and the Devil is in past tense, so at least we know it can be done well.

The narrator “I” is Marbles the cat, friend to D, a ten year-old boy. They have adventures together in the Great Underground Empire. You can meet them in this short story for young people. This game is part of what will ultimately be a series of stories about their journeys together. I think I’ll start this game with with a short little speech from D. He can get us up to speed. Here we go, the first text of the game:

when play begins:
	say "'Gee whiz, Marbles! It feels like days since we left the Royal Museum this morning! We just barely escaped the Caverns of Despair, where Frambozz the Adequate tried to mix parts of us in his so-called 'potion of benevolence.' That's to say nothing of the serpent-robins['] grove, or the apiary of meticulous spiders! Thank goodness we've reached this totally safe-looking, well-lit theater just a block or two away from the Thriff Guild of Enchanters. If we hurry, we can still get there in time for dinner with Guildmaster Fweep and his lemur familiar, Loretta.'";
	now the story viewpoint is first person singular;
	now the story tense is past tense.

In past and currently unannounced future games, I’ve hidden the status bar during a prologue sequence. I don’t need that yet; this is a short paragraph, and the title banner follows close behind. This may well change once I introduce some configuration choices for graphics and story mode. I’ll leave it be for now.

You may have noticed the “now” constructions for viewpoint and tense. Inform 7 makes allowances for such authorial preferences in the Standard Rules and elsewhere. They’re both variables that have starting values, so we have to assert these new values in action processing.

Organizational problems.

My plan is for the player’s perception of the game world to change. Marbles’s perception of the stage area will change quite a bit and the story progresses. I need to come up with a way to manage these changes and their corresponding texts in a way that doesn’t generate a lot of spaghetti code. Inform 7 has great options for conditional and variable text right out of the box, but I don’t think they’ll work for this project as-is. For instance, if I change the description of the stage four times, I could write a rule with a lot of conditional text (with a lot of conditions):

the description of center stage is "[if the massive frob is illuminated]A massive illuminated frob beams[otherwise]The darknened frob glowers[end if] at the center of the stage.

[if the player has not eaten the marshmallow fluff]My goodness, I am starving! All I can think of is delicious marshmallow fluff! I look at the frob [otherwise]...

And so forth. This would get pretty messy. Even if we could keep track of it all, we might want conditions for our conditions. What if we’ve eaten, the frob is dark, and D is pointing the spotlight at something (from his place in the spotlight booth, where we can see him)?

I have a couple of ideas. We could do elaborate substitutions, since they support some coding features (did you know that?).

to say the description of center stage:
	if the massive frob is illuminated:
		if the player has eaten the marshmallow fluff:
			say "Thank goodness I ate that marshmallow fluff! The massive frob would otherwise sap my strength!"

…and so forth. Now, this kind of construction would probably wind up scrolling through multiple pages, since I’m not writing full room descriptions. We would invoke it with

the description of center stage is "[description of center stage]".

Alternately, we could mix and match, putting some conditionals in the “say” and others in the “description” statement.

the description of center stage is "[if the massive frob is illuminated][illuminated description][otherwise][darkened description]".

We could handle things in action processing instead:

after d pointing the spotlight at the massive frob:
	now the massive frob is illuminated;
	now the description of center stage is "[illuminated description]".

That would work fine, and would keep statements brief, but I don’t like having room description rules all over the place. Remember, we’re dealing with at least four rooms here.

What about tables? I’m just spitballing things here, thinking as I type. Maybe we could have a little table lookup rule that grabs the right (hopefully) description when it’s needed.

We could make some values…

stage of a game is a kind of value.
the plural of stage of a game is stages of a game.
the stages of a game are part I, part II, and part III.
the current act is a stage of a game that varies.
the current act is initially part I.

then tie those values to entries in a table…

table of room descriptions
current act	description
act I	"descriptive text."
act II	"descriptive text."
act III	"descriptive text."

I could then print whatever text corresponded to the value of current act. That might work out better. At least everything is in one place. In trying to prove this out, I made a short demo. It’s probably easier to look at than it would be for me to explain.

Click here to launch the demo in a code snippet.

I think tables will make the most sense. Especially if I find myself needing separate paragraphs for scenery objects and what-not. I could always to “report looking” rules or some other tactic to look at other tables. I think I should keep things modular, and if I don’t need as much extensibility as I think, that’s ok. It won’t be the first time I’ve overengineered something!\

Making a scene.

I think I’m overlooking something, though. Inform has built-in support for breaking up games into parts based on narrative action: scenes! However, I’ve never used one. [brightens] That really makes me want to try scenes. I’ll step away for a minute for some experimentation….

…OK, I think scenes will be good. I can use conditions like this…

if act one is happening:

Scenes can overlap (there’s one for the entire game), so I want to make sure things don’t get weird. I’ll chain them together.

prologue is a scene.
act I is a scene.
act II is a scene.
act III is a scene.

act I begins when play begins.
act II begins when act I ends.
act III begins when act II ends.

I’m sure I’ll come up with something clever later, but this is enough for us to start. I’ll try a first room….

OK, I’m back. Scenes can overlap, as I’ve already said. That makes referencing an active scene in a table more complicated than I first guessed. Here’s what I learned:

A scene can be assigned properties and values, just like the things I’m used to working with. To get a “current scene” that’s valid for our purposes, I need to assign a common property to these sequential scenes:

a scene can be linear.
a scene is usually not linear.

If I make the above-referenced scenes linear, I will have a series that can only happen one at a time while also having a shared property. I should be able to determine which one is active in this way. Since I’ll need to check this all the time, I’ll just make a phrase that I can reuse over and over.

to determine the present scene:
	repeat with act running through scenes:
		if act is happening and act is linear:
			now the present scene is act;

In Inform 7, active scenes are “happening.” I can check all scenes for one that is both active and linear. Since we can only have one active linear scene at a time, we can always find the relevant rows for our description tables. The final construction for describing the stage looks like this:

the description of at center stage is "[the stage's description]".

to say the stage's description:
	determine the present scene;
	choose row with a present action [a table column] of the present scene in the table of stage descriptions;
	say the description entry.

Pretty clean! Right now, I have my description table in the “tables” section of the source rather than “Part 2 – at center stage.” Why? It’s been my experience so far that when I’m scrolling through rooms, I’m looking for actions and things. I don’t revisit room descriptions nearly as often. My guess is that a big table in the geography section would slow me down. I can always move it if that turns out to be wrong.

I also changed the opening crawl to print the text that you’ve already seen, then the banner, then some more text. I put a “press any key” prompt in there, too. I know some people hate those, but I’m not 100% sure if that’s my audience. It’s always ok to wait and see what testers think! If you want to customize how/when the banner prints, there are a few different ways. Here’s what I did:

The display banner rule is not listed in the startup rulebook.

when play begins:
	say "[some text here]";
	say "[pb]";
	say "Paw at the keyboard to continue.";
	wait for any key;
	say "[pb]";
	now the story viewpoint is first person singular;
	now the story tense is past tense;
	say the banner text;
	say "paragraph break"[pb]";
	say "[some more text]".

Since Inform 7 stories are made up of rulebooks and rules, delisting a rule takes it out of the game completely. Left to its own devices, my game will never print the banner unless I do it myself. It’s considered poor form to completely omit the banner from a game (delaying it is an accepted practice), so consider delisting the rule a commitment to print it at some point.

As I’ve previously mentioned, “[pb]” is my shortcut for paragraph break. There are no spaces before or after printing the banner text, so I have to provide my own.

There’s still so much to do! But I feel we have a great setup for this design. A recap:

  • The protagonist, Marbles the cat, can look into rooms and (eventually) communicate with her friend D from one end of the theater to the other.
  • I have a mechanism for enumerating nondescript items in other rooms (with some more decisions to make later).
  • I’ve decided to manage the “chapters” of this story in terms of scenes. It seems like there’s a lot of potential there, and I’m excited to dig in.
  • I can automate the printing of text descriptions according to the current scene.
  • I’ve finally gotten a bit of text going. I think we’re underway.

The drive where source code for this project is stored is here.

Today’s source code is here, as a plain text file. Copy and paste into and Inform 7 IDE for comfortable viewing.

Next.

More text, I think, and seeing what happens when we shift from Prologue (a short scene) to Act I. Get in touch with questions!