Continuing to build our framework for a variable IF text.
last time, on let’s make IF…
Last week, I added support for “fake” endings, as well as a clear screen functionality to present eight individual “poems” in a recognizable IF format. The techniques should be largely familiar at this point: text substitutions using tables. You can get a refresher here.
more of the same.
As promised last time, I’m not going to write about the same techniques over and over again. This post will consist mostly of updates based on things we’ve done before. We can start by adding an opening “blurb,” or preamble, to our texts. We already have a “before looking” rule that we can hitch our new text to.
before looking:
say the fake banner;
say the preamble.
I’ll follow through with a “to say” definition that references a table, and make the relevant table. You can check it out in the updated source code I’ve shared below.
We’ll also need to change the room description to match our current model. That will work the same way: a definition and a table.
the description of ABR is "[a variable room description]".
to say a variable room description:
choose row with an index of the magic number from the table of room descriptions;
say the text entry.
Likewise, a text for the table (the actual thing in the game world, not a code table in our program) printed during the room description (this is a “paragraph about” and not a “description of” the table). We already had something for this, but let’s update it to work the way our other texts do.
rule for writing a paragraph about the table:
if something is held by the table:
say "[a table text]";
say line break;
list the contents of table, with newlines, indented, with extra indentation;
otherwise:
say "This is an error condition. Something should always be on the table.";
now the table is mentioned.
to say a table text:
choose row with an index of the magic number in the table of actual table information;
say text entry.
Note that I’ve included an error message. I don’t intend for the cards to be actually takeable, but I haven’t done anything to prevent taking them yet. I’ll leave something in the code as a reminder and/or warning.
Room names:
the printed name of ABR is "[ABR]".
to say ABR:
choose row with an index of the magic number from the table of room names;
say the text entry.
Zooming along! The last item on our list is a means for printing multiple card names. Since this is part of a complicated process for listing the table’s contents, things are a bit trickier. Not much, though! We’ve done this all before. Here’s our list-printing customization as it is right now:
rule for printing the name of a tarot (called the current card) while listing contents:
say "[printed name of the current card][if the clicker of the current card is not zero] (times drawn: [clicker of the current card])".
Since we already have a known noun (the current card), we can use that to look up the right information. First, a short table of contents.
table of card references
tarot table
redc table of red cards
bluec table of blue cards
yellowc table of green cards
orangec table of orange cards
Since we have tied individual tables to each card, it becomes a matter of checking the right table against the magic number–familiar territory by now. Here’s the final rule:
rule for printing the name of a tarot (called the current card) while listing contents:
choose row with a tarot of the current card from the table of card references;
let t be the table entry;
choose row with an index of the magic number from t;
say "[card entry][if the clicker of the current card is not zero] (times drawn: [clicker of the current card])".
There! Since this is only happening during listing, we can leave the “real” printed name alone in case we need it for something.
I mentioned needing to sync up magic number across all outputs, so I moved the “increment the magic number” phrase to the very end of the turn. I also added numbers to our tables, just so we can see that everything is lined up. Here’s what turn 4 of our “game” looks like:
Portrait With Wolf ^_^
An absolute delight
Release 4 / Serial number 241007 / Inform 7 v10.1.2 / F
Preamble 4.
Room name 4.
Room description 4.
Table paragraph 4.
a red 4
a blue 4
a green 4 (times drawn: 1)
an orange 4 (times drawn: 2)
>
a placeholder for randomness.
green. 4
This is a fake tombstone entry from the table of fake assertions. 4
*** fake epitaph 4 ***
Press any key to *RESTART*! 4
There we are! Everything’s pulling from the right tables, at the right time. As always, you can check the updated source code for more details. You can copy and paste it directly into your own IDE and run it for yourself!
next.
The to-do list is getting shorter! We need to restrict the parser so that players don’t run off with our cards. Similarly, I’ll have to customize parser errors and default messages for our game. That’s an important aspect of any polished game!
I’d like to cap things off with an essay about playtesting… within two weeks, I hope. Stay tuned.
One response to “let’s write IF #13: further framings”
-

[…] let’s write IF #13: further framings […]
LikeLike

Leave a comment