I’m helping code a game for someone. They would like “say yes” to be an option equivalent to “yes” in the “if the player consents” questions.
I tried redirecting “say yes” to the ‘saying yes’ action. I even tried ‘after reading a command’ but ‘if the player consents’ doesn’t seem to be wired in a way that ‘after reading a command’ affects it.
Is there any nice way to add this feature without significantly changing the behavior of ‘if the player consents’ in possibly gamebreaking ways?
This is the implementation of “whether or not the player consents”:
To decide whether player consents
(documented at ph_consents):
(- YesOrNo() -).
Let’s dig up that I6 routine:
[ YesOrNo i j;
for (::) {
if (location == nothing || parent(player) == nothing) KeyboardPrimitive(buffer2, parse2);
else KeyboardPrimitive(buffer2, parse2, DrawStatusLine);
#Iftrue CHARSIZE == 1;
j = parse2->1;
#Ifnot;
j = parse2-->0;
#Endif;
if (j) { ! at least one word entered
i = parse2-->1;
if (i == YES1__WD or YES2__WD or YES3__WD) rtrue;
if (i == NO1__WD or NO2__WD or NO3__WD) rfalse;
}
YES_OR_NO_QUESTION_INTERNAL_RM('A'); print "> ";
}
];
Indeed, it doesn’t interact with “reading a command” at all—it gets input directly from the keyboard and then parses that input on its own. (It uses buffer2 and parse2 so as not to interfere with the main parse results, which are in buffer and parse.)
So if you want to accept “say”:
Include (-
[ YesOrNo i j;
for (::) {
if (location == nothing || parent(player) == nothing) KeyboardPrimitive(buffer2, parse2);
else KeyboardPrimitive(buffer2, parse2, DrawStatusLine);
#Iftrue CHARSIZE == 1;
j = parse2->1;
#Ifnot;
j = parse2-->0;
#Endif;
if (j) { ! at least one word entered
i = parse2-->1;
if (i == 'say' && j > 1) i = parse2-->2; ! ← this is the new part!
if (i == YES1__WD or YES2__WD or YES3__WD) rtrue;
if (i == NO1__WD or NO2__WD or NO3__WD) rfalse;
}
YES_OR_NO_QUESTION_INTERNAL_RM('A'); print "> ";
}
];
-) replacing "YesOrNo".
Ahh, right, I forgot about the format of the parse buffer. The addresses of the dictionary entries (what we want to compare here) are interleaved with data about their position in the text buffer. So you need to skip ahead to find the next actual dictionary word.