Expanding "if the player consents"

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".

(Note: not tested!)

1 Like