Login
Remember
IF Answers
Ask a Question

# How do I change 'if the player consents'? pre-Inform 6L or post-

0 votes
123 views
asked Mar 23 in Authoring by AndrewS (250 points)
recategorized Mar 27 by Alex
This is something that prompted me to look into Inform 6, which isn't critical, but just knowing you can tinker helps get rid of some helplessness.

- inform6
- inform7
- inform7-6l

## 2 Answers

+2 votes
answered Mar 23 by Ryan Veeder (290 points)

In Inform 7 version 6L02 and onward, the response "Please enter yes or no." is stored as "The yes or no question internal rule response (A)". We're able to change it easily with declarations like:

    The yes or no question internal rule response (A) is "She grabs your arm plaintively. 'Please, just say yes or no, Bastian! Fantasia is counting on you!'"

But this change will also apply to out-of-world contexts where the customized response may not be appropriate, such as after the player is asked "Are you sure you want to quit?"

Here's how I worked around this:

    The yes or no question internal rule response (A) is "[Yesorno]".

    Yesorno is a text that varies. Yesorno is "Please answer yes or no."

    Instead of examining the Childlike Empress:
        say "The Childlike Empress asks you if you will swear to save Fantasia from the Nothing, is what I remember happening. I only saw like half of this movie, and that was about fifteen years ago.[paragraph break]Will you so swear?";
        now yesorno is "She grabs your arm plaintively. 'Please, just say yes or no, Bastian! Fantasia is counting on you!'";
        if the player consents:
            say "Your bravery brings the Empress to tears.";
        otherwise:
            say "Your betrayal brings the Empress to tears.";
        now yesorno is "Please answer yes or no."

The order of "now yesorno is the special response", the "if the player consents..." branch, and "now yesorno is the regular response" is important, and easy to mess up, but when you get it right, this framework lets you do some neat stuff.

commented Mar 23 by AndrewS (250 points)
That's very nice! I have to admit I'm still not ready to jump to 6L for my own silly reasons, but I used the internal rule response in an extension. The code is below. It allows you to unblock hints, sort of.
The restore the game rule response (B) is "[if hint-block is true]You had hints blocked completely in your previous section, but now they are temporarily turned off instead. You can type HINT ON to reactivate them[true-it].[else][end if]"
commented Mar 23 by Ryan Veeder (290 points)
I hadn't caught that your answer was specific to pre-6L Inform. This may be one of those cases where it'd be useful to put version-specific tags on questions.
And answers. I don't think you can tag answers, though.
commented Mar 23 by AndrewS (250 points)
Good point. I edited in the 6L caveat. Looks like I have a bit of learning to do with this.
0 votes
answered Mar 23 by AndrewS (250 points)
edited Mar 24 by Dannii

This is a bit tricky. The game asks for a yes/no response, and the default seems a bit stuffy at times.

To do this, we look in Extensions\Graham Nelson and Standard Rules.i7x for "consents" and we find this:

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

The parentheses denote I6 code, but don't worry. We can search for that in Reserved.You can grep (grep -i yesorno *) , or use windows search or whatever. It turns out there's a file called parser.i6t which has YesOrNo! A lot of the code may look semi-sensible, but this line looks promising, with a cursor after it:

> L__M(##Quit, 1); print "> ";

So, say,

> print "There is no escaping! You must answer yes or no, or y or n if you're in a hurry >";

Is doable. Maybe you can think of a better response, or even use arrays to make the parser more impatient (but make sure it makes the player laugh.)

There's one more thing, though. You don't want to change any of the lines in parser.i6t, since that would muck up your next project. Here's what you can do, though:

> Include (-
> [ YesOrNo i j;
> 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 (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 "But Thou Must answer yes or no > ";
> }
> ];
> -) instead of "Yes/No Questions" in "Parser.i6t".

This looks like a mouthful just to change one line, but I really just cut and pasted YesOrNo from Parser.i6t, changing the L__M((##Quit,1).

If you're wondering where ##Quit comes in, you can search for Quit in Language.i6t.

commented Mar 23 by AndrewS (250 points)
As a followup:
I also had a small stub that causes the asker to get mad and assume you mean something if you waffle 4 times in a row, but I really like this, especially since you can also give different responses for too many/too few words.
(The inspiration for this was code from Threediopolis.)
chapter Ed's question
to decide what number is Ed-blab:
(- EdBlab() -)
Include (-
Array edMad --> 4 "'Yes or no. Not rocket science.' Whew. He's a bit...direct." "'C'mon, kid, you can't answer an easy yes-no question...'" "'Last chance. No wrong answers. Only two possible.' He's a little upset, but a simple yes/no will probably make him happy." "'Okay, you asked for it. Or you didn't.'";
Array edSilent --> 4 "'Yeah, yeah. Doer not a talker. But I need a simple yes or no.'" "Ed out-silences you into feeling you really should answer yes or no." "With a quizzical frown, Ed moves a hand up, then down. He's a little ticked, but a simple yes/no will change that." "Ed shrugs.";
[ EdBlab i j k;
k = 0;
for (::) {
if (location ~= nothing && parent(player) ~= nothing) DrawStatusLine();
KeyboardPrimitive(buffer, parse);
#Ifdef TARGET_ZCODE;
j = parse->1;
#Ifnot; ! TARGET_GLULX;
j = parse-->0;
#Endif; ! TARGET_
k++;
if (j) { ! at least one word entered
i = parse-->1;
if (i == YES1__WD or YES2__WD) rtrue;
if (i == NO1__WD or NO2__WD) rfalse;
if (j > 1) { print "'No biographies. Yes or no.'"; }
else { print (string) edMad-->k; }
} else { print (string) edSilent-->k; }
if (k == 4) return 2;
}
];
-)
let xyz be Ed-blab;
if xyz is 2: end the game, or whatever
if xyz is 1: allow minor cheats
if xyz is 0: hard mode

## Related questions

- How can I set the player smell in Inform 6?
- How to get rid of a rule that's blocking what I want the player to do? (Inform 7)
- Inform: How do I find the word count for text the player can read?
- Inform: How do I get the player to input a name for themselves? The name keeps changing to whatever the player typed last!
- How do I display the full / initial room description when the player looks?

...