Asking a player for confirmation (Adv3lite)

I’d like to ask players for confirmation before they commit a particularly potentially dangerous action. Something like, “are you sure you want to do this? (Y/N)” and then parse player input.

What’s the simplest way to implement this?

Library Manual, Part VI, “Utility Functions” page mentions a yesOrNo() function. There’s no code example with this, and I’ve never used it. Try experimenting with it … perhaps in a code block in a check() for the action.

Rather than use this type of code, I would usually try to write an in-story hesitation:

“As your hand reaches toward the switch, you hesitate. You find yourself wondering if something bad might happen.”

This block of code would also set a flag value to indicate that the hesitation message had been printed. If the player types ‘g’ (or ‘again’), or returns to the command later, the hesitation message would be bypassed and the action would proceed in the usual way.

Yeah, I’ve been trying to figure out which method (Yes or no or requiring a confirmation with a second attempt) would better suit the game I’m writing. I’m aiming to make it user friendly to players new to parser-based IF.

I wonder if the warning/confirmation cycle would be more elegantly handled with a flag or some kind of list [‘first response’, function to be called as a result of warning, ‘second response’, function to be called as a result of confirmation].

You could do it with a StopEventList, certainly … but the code would be more complicated. The results for the player should look identical.

Here’s a test case – simple code:

+ apple: Food 'apple; apple' "It looks scrumptiously edible. " warningGiven = nil dobjFor(Eat) { check() { if (!warningGiven) { warningGiven = true; "Hmm ... isn't that the apple the Wicked Witch gave you? While cackling maniacally? "; } } action() { "Oh, no! It was poisoned! You're dead! "; finishGame(ftDeath); } } ;
Here’s the output:

Yeah, I went with warning/verification that looks almost identical to that.