top expert

i am my own ghost

Let’s Make IF #9: flipping the switch.

last time, on Let’s Make IF.

Yesterday, I made a little more progress in getting Marbles to the exit doors:

  • I found a mistake I that I made copying a phrase for printing room descriptions. Some of you may have wondered: couldn’t I have done a single rule with another “table name that varies?” The answer is yes, probably. I might look into that. Right now, my priority is getting the switch at the back of the theater flipped. That will give us a tiny working snippet of code, something that begins and ends.
  • I wrote some descriptions (one local and one remote) for the Auditorium area. I also created “chair” and “chairs” scenery objects with some instead rules that prevented any sort of action involving them.
  • I merged in last week’s rules for describing D’s movement from the stage to the main exit. It was mostly painless, only requiring a few additional lines of code.

Today: just a couple of new descriptions, and one new action.

more text.

We’ll repeat a familiar process and make rules and a table for describing the main exit locally and remotely. I’ve decided to disable remote printing of locale paragraphs for now, at least until I have a clear idea of how they’ll be used. A lot of this text is merely functional, and I’ll give it more TLC as the project progresses.

As I began testing Marble’s trip from center stage to the main entrance, I noticed that sometimes–not every time–it made sense to print “the” before the name of a room, and sometimes it didn’t. Sometimes, names should be capitalized, but not always.

Off in the distance, I saw D arrive at Main Entrance.

That isn’t great, is it? You can make printed names of things conditional, so I quickly did one of these for every room:

the printed name of main entrance is "[if the location is main entrance]Main Entrance[otherwise]the main entrance[end if]".

In the location, I think the most common occasion for printing the name of a room will involve the bolded text above a room description. Otherwise, Inform will probably be printing room names while describing D’s actions (“I saw D arrive at the main entrance.”)

Speaking of D: I was hoping this day would not arrive so soon, but “D” can’t remain D’s name since it is already an abbreviation for down. That wouldn’t necessarily be a huge deal, but “down” is the way out of the spotlight booth, and I don’t think any other direction would make sense. I’ve changed it to “K” temporarily (as an affectionate nod toward Kafka) but am open to other letter suggestions. Perhaps Dee? I dunno. Anyway, since the story is still small and I can do case sensitive find/replace, this took less than a minute or two to change. It won’t be hard to change it again.

I need an “every turn” rule for the main entrance. I’ll use it to describe K’s interaction with the door. My goal is for the player to *MEOW AT THE LIGHT SWITCH* (Marbles is a cat, after all), so I’ll make the switch the “hinge” for our conditional text. First, some rules I can use throughout the game. The first is from Inform’s documentation:

a thing can be examined or unexamined.
a thing is usually unexamined.
after examining something:
now the noun is examined.

This just gives me a way to modify rules based on whether or not something has been examined. An important note for these “after” rules: they don’t work if action processing doesn’t get that far (i.e., if stopped by an “instead” rule), so I have to be mindful of that kind of thing.

The second rule involves a new action:

meowing at is an action applying to one visible thing.
understand "meow at/-- [something]" as meowing at.

If you’re new to making new actions or new synonyms for actions, you might wonder about the “at/–” construction. The slash in an “understand” phrase is an and/or indicator. As is the case with table entries, “–” means empty or, conversationally, “nothing.” Here, that means that both “meow light switch” and “meow at light switch” are both valid commands. Generally speaking, it is good to provide players with all (sometimes a tall order) reasonable alternatives for a command. Once the action is in place, I’ll imitate Dr. Nelson’s “examined” assertion and rule.

a thing can be discussed or undiscussed.
after meowing at something:
now the noun is discussed.

Now that the “examined” property is sorted, let’s take a look at that “every turn” rule:

every turn when K is in main entrance and marbles is in main entrance during prologue:
if the current action is not meowing at the light switch:
say "[if the light switch is unexamined][one of]K tried the handles of the exit doors, but they didn't budge.[or]K looked at the doors, clearly annoyed.[or]K knocked on the doors experimentally, but no one answered.[or]K looked at me. 'Gee whiz, marbles! Do you think this is the only way out?[or]K glanced around the room, as if something useful might be nearby.[stopping][otherwise]I thought that maybe K hadn't noticed the light switch yet. Maybe it would have helped if I *MEOWed AT THE LIGHT SWITCH*?[end if]".

The “current action is not” bit is to avoid printing text about meowing twice in one turn. Otherwise… it’s a little complex at first glance. Note the “[if the light switch is unexamined]” condition. It selects a [one of… stopping] construction that will describe K’s actions and frustrations for a few turns before repeating a message about him looking around for something useful. That’s before Marbles looks at the switch. Afterward, the player gets a very direct message suggesting that they *MEOW AT THE LIGHT SWITCH*. This is merely an opening area. One important thing is the story, and the other is teaching the player to *MEOW* at things to make progress.

ending the prologue.

The meow action ends the prologue. What’s that like? First, the action must process.

Carry out meowing at the light switch:
say "I told C about the light switch, since it seemed important. 'Wow, would you look at that? A light switch!' He flipped it and theater lit up immediately. From where we stood, we could see the entire stage and all of its clutter. Even though it was a lot to look out, one thing stood out from the rest. A massive, black box, large enough to hold one or more humans seemed rested on its side near the center of the stage.

Its sides seemed to waver or ripple as if it were painted by some kind of magical brush. C and I have seen that kind of thing before, you know, in a village near the Tears of Entharion. This seemed different. 'Wow, T, there's something dangerous about that box! I guess we ought to go and check it out!'

There was nothing to do but follow him; there was no telling what kind of trouble he might have gotten into otherwise!".

the prologue ends when the light switch is discussed.
when act i begins:
say "[bt]ACT ONE[rt][pb]";
try looking.

Note that I have already set act i to begin when the prologue ends, so I don’t need to worry about that. Why “ACT ONE” there in bold? For now, it’s just a good mile marker. I’m not sure if it will stay. I’ll just leave it be until I have more text to look at.

What else? I’ve committed to having D cross the theater again. This time, though, the rooms will have different descriptions and possibly allow more interaction. I can’t let this be a just bunch of dull back and forth trips!

I’ll have to assign a new fascination to D, of course, but the further I go, the more technical foundation I should have. There are mechanisms to handle D’s movement (I can’t help but keep calling him “D!”), to describe his interactions, and to allow Marbles to look (and meow) at remote locations and things. It’s good to have that stuff out of the way, because something pretty complicated lies ahead.

As always, periodic updates to source code are stored here.

Here is today’s updated source.

next.

D and Marbles will be able to see and do more in the newly lit theater, including having their first up-close look at the mysterious box.