I6 stubs for I7 programmers

I never really got to I6–I remember being intimidated by Alan way back when.

Seeing I6 source code has made it a lot more logical for me, but I’d never have gotten started without I7. Still, chunks of I6 have been useful to me.

I’ll list some below, and as I find them I hope this isn’t flooding things if I post every other day or so. I hope it’s useful to other people.

A lot of this code is from Climbingstars, who sadly hasn’t been active on the intfiction.org boards for a while. But he was a big help to me testing my games and offering code. Here is one of the first things he gave me. It allows you to set the pronouns to what you want. Thus, if you make an item disappear, you can switch “it” to something else, or you can even allow “them” to equal “it” when it makes sense, or vice-versa.

To set the/-- pronoun it to (O - an object): (- LanguagePronouns-->3 = {O}; -).
To set the/-- pronoun him to (O - an object): (- LanguagePronouns-->6 = {O}; -).
To set the/-- pronoun her to (O - an object): (- LanguagePronouns-->9 = {O}; -).
To set the/-- pronoun them to (O - an object): (- LanguagePronouns-->12 = {O}; -).

Additional tip: the PRONOUNS command tracks which pronoun does what. I think this may be in Inform 7 6L’s docs but it wasn’t in 6F.

I just (re-)found this code, which works only for ZSCII: (characters 32-128 of ASCII)

To say character number (N - a number): (- print (char) {N}; -)

I also habitually use this code from Zarf. There’s Inform 7 code as well, but I think it’s so handy that I want to share the whole thing.

chapter transcripting

Include (-
[ CheckTranscriptStatus;
return ((0-->8) & 1);
return (gg_scriptstr ~= 0);

To decide whether currently transcripting: (- CheckTranscriptStatus() -)

[thanks to Zarf for the above code. It helps a tester make sure they're testing after their first comment.]

report switching the story transcript on:
    if currently transcripting:
        say "Thanks for doing this! Email can go to [email].";

check quitting the game when currently transcripting:
    say "Thanks for taking a transcript. Please send it to [email] and I'll be grateful. Thanks!";

after reading a command:
    if the player's command matches the regular expression "^\p" or the player's command matches the regular expression "^<\*;>":
        if hint-to-file is true:
            append "COMMENT: [the player's command]" to the file of roilhints;
        if currently transcripting:
            say "Noted.";
            if ignore-transcript-nag is false:
                say "You've made a comment-style command, but Transcript is off. Type TRANSCRIPT to turn it on, if you wish to make notes.[paragraph break]The long version of this nag will only appear once. You may press any key to continue.";
                wait for any key;
                now ignore-transcript-nag is true;
                say "(Comment not sent to transcript.)";
        reject the player's command;

First, to help with debugging for a runtime error that happens before you can type RULES:

to rulesOn:
    (- RulesOnSub(); -)

I also like this piece of code:

Include (-
    has transparent talkable
-) when defining spec-o-scope.

The i6 code defines talkable as, say, a microphone versus an actual person. I’m just really pleased with how smooth it can be to follow the I7 code to I6 code to rules.

And also, this may be more “how to hunt things down in I6/I7,” but in Threediopolis, I repeatedly ran into an annoying error where I tried to hack the yes/no parser so that Ed Dunn got annoyed and kicked you out if you dithered four times in a row.

if the player consents:
  (do something)

To find what this touched in I6, I did

cd "c:\Program Files (x86)\Inform 7\Inform7\Extensions\Graham Nelson"
grep -i consents *.i7t


To decide whether player consents
    (documented at ph_consents):
        (- YesOrNo() -).

And modified YesOrNo with a bunch of if-then statements, and I threw in an awful hack.

I didn’t realize that I could make my own condition, e.g.

if the player accepts Ed's help:
  (do something)

To decide whether player accepts Ed's help:
        (- YesOrNoEd() -).

And I could just modify YesOrNo to a new function. Which I poked at so it worked similarly.

(quivers a bit, bleeding from the eyes)

It’s not too bad once you get used to it. And you only really need to cut and paste certain code.

Zarf just gave a REALLY useful example on intfiction.org, of how to force no line breaks.

To say period: (- print "."; -).

It’s been too long here. This is an example where I wanted to shorten a verb, but if I tried “r” I’d get “What do you want to r?” This makes it “read.” You can see other uses here.

Include (-
Replace LanguageVerb;
-) after "Definitions.i6t".

Include (-
[ LanguageVerb i;
    switch (i) {
               print "take inventory";
      'a//':   print "ask about";
      'l//':   print "look";
      'x//':   print "examine";
      'gt//':   print "go to";
      'r//':   print "read";
      'z//':   print "wait";
      default: rfalse;
-) after "Language.i6t".

By the way, GT = go to = going to a room, or to where a specific object is. It’s handy for a semi-big game.

The original LanguageVerb has just i, l, x and z.

This isn’t much, but it follows up on my earlier code. And it may have holes, anyway. But if you want to enable it, then I hope it’s clear what to modify…based on YesOrNo in parser.i6t.

when play begins:
    say "Do you wish to enable profanity?";
    let qq be swear-decide;
    if qq is 2:
        say "You hesitated, so I'll say, no.";
    else if qq is 1:
        say "Wuss.";

To decide what number is swear-decide:
    (- OKSwear(); -)

Include (-

Global copout;

[ OKSwear i j;
    copout = 0;
    for (::) {
        #Ifdef TARGET_ZCODE;
        if (location == nothing || parent(player) == nothing) read buffer parse;
        else read buffer parse DrawStatusLine;
        j = parse->1;
        #Ifnot; ! TARGET_GLULX;
        KeyboardPrimitive(buffer, parse);
        j = parse-->0;
        #Endif; ! TARGET_
        if (copout == 4) { return 2; }
        if (j) { ! at least one word entered
            i = parse-->1;
            if (i == YES1__WD or YES2__WD or YES3__WD) rtrue;
            if (i == NO1__WD or NO2__WD or NO3__WD) rfalse;
            print "I won't judge. Yes or no. > ";
        } else { print "No need to hesitate. Yes or no. > "; }