Disallowing UNDO for selected commands, part deux

Hey All–

Some time ago I had a very cringy thread about disallowing undo selectively using Erik Temple’s Undo Output Control extension. That thread devolved into a shitshow since I couldn’t install an extension, and I’m not eager to revive it, hence the new thread.

The following code works great in my little test game, but I’m wondering if there’s anything here that will come back to bite me (or the player) if I include it in my game. I’m hesitant to do all the work to put it into my game without knowing if there’s a big red flag. Can anyone see any problems this might cause?

"Bear Naming" by Amanda Walker

Include Undo Output Control by Erik Temple.

The last action is an action that varies.
	
First after doing something:
	now the last action is the current action;
	continue the action.

Before undoing an action when the player is irreversible:
	say "Sorry, UNDO is not allowed at the moment.";
	undoback in zero turns from now;
	rule fails.

At the time when undoback:
	now the player is not irreversible.
	
Something can be NameChoosing. Something is usually not NameChoosing.

Something can be irreversible. Something is usually not irreversible.

Den is a room. 

The stuffed bear is here.

Father is a man in Den.

Report taking the stuffed bear:
	now the player is NameChoosing;
	now the player is irreversible;
	say "Your father asks, 'What will you name the stuffed bear?[paragraph break]1.) Ignatius[line break]2.) Hippolyta[line break]" instead.
	
After reading a command:
	if the player is NameChoosing:
		if the player's command matches "1":
			now the player is not NameChoosing;
			now the printed name of the stuffed bear is "Ignatius";
			say "Your father says, 'Your grandfather's name! Good choice.'" instead;
		otherwise if the player's command matches "2":
			now the player is not NameChoosing;
			now the printed name of the stuffed bear is "Hippolyta";
			say "Your father says, 'Your grandmother's name! Good choice.'" instead;
		otherwise:
			say "Your father frowns and says, 'You can't do anything until you name that bear that I worked so hard to pay for and gave you because I love you. Now pick 1 or 2, damnit!" instead;
	otherwise:
		continue the action.
1 Like

Since you’re depending on a timed event to change the reversible property, the timed events rule has to run for that to take effect. At the first prompt after selecting a name, this will not have happened because technically you stopped the turn sequence at the parse command rule by using instead within your say statement. (Take a look in the Index under Rules/Standard/The top level and click to expand the turn sequence rules.)

I added an every turn rule as a proxy for the rest of the turn sequence to help illustrate the potential problem:

Every turn (this is the machine that goes bing rule):
	say "bing."

This is a sample transcript:

>X FATHER
You see nothing special about Father.

bing.

>TAKE BEAR
Your father asks, "What will you name the stuffed bear?

1.) Ignatius
2.) Hippolyta

bing.

>Z
Your father frowns and says, "You can't do anything until you name that bear that I worked so hard to pay for and gave you because I love you. Now pick 1 or 2, damnit!

>1
Your father says, "Your grandfather's name! Good choice."

>UNDO
Sorry, UNDO is not allowed at the moment.

It’s not clear that you are intentionally trying to prevent an >UNDO at that point.

1 Like

OK. I am trying to prevent the player from undoing choosing a number from a menu. When I add things that change the state of something into “After reading a command,” they still function after preventing UNDO.

So yes, I only want to prevent the player from taking back whatever number they picked. When you play a choice-based game, you very often have to live with the consequences of your choices, and I wanted to do that here, but only for picking numbers from a choice menu. So I think this will work. I just wondered if this was some deep-level interference that would wonkify other things.

Well, the way that you’ve set it up, you can get this…

>TAKE BEAR
Your father asks, "What will you name the stuffed bear?

1.) Ignatius
2.) Hippolyta

>1
Your father says, "Your grandfather's name! Good choice."

>LOOK
Den
You can see Father here.

>X FATHER
You see nothing special about Father.

>UNDO
Sorry, UNDO is not allowed at the moment.

That’s because the only thing setting irreversible for the player is an attempt to >UNDO. For what you want it seems like that should be set (and the timer for undoback set) when picking up the bear.

I know that you prefer to figure everything out on your own, but since the stuff related to >UNDO is pretty intricate at a low level, here’s an implementation that I worked out that hopefully does what you want to do. It passed cursory testing but might still have bugs.

Ignatius or Hippolyta
"Ignatius or Hippolyta"

Include Undo Output Control by Erik Temple.

Den is a room. 

Father is a man in Den.

The stuffed bear is here. Understand the printed name property as describing the bear.

Definition: The bear is unnamed rather than named if the printed name of it is "stuffed bear".

To name (item - thing) as (name - text):
	now the printed name of item is name;
	now the item is proper-named.

undo verboten flag is initially false. [a truth state; workaround for the inability to start a scene based on the ending of a type of scene]

A scene can be irreversible. A scene can be choiceful.

After reading a command when a choiceful scene is happening and the player's command does not match "[number]":
	say "[bracket]Please make a selection by typing a number.[close bracket][line break]";
	reject the player's command. 

When an irreversible scene ends:
	now undo verboten flag is true.

Before undoing an action when an irreversible scene is happening:
	say "Sorry, UNDO is not allowed at the moment. You must make a choice.";
	rule fails.

Undo Prevention is a recurring scene. Undo Prevention begins when undo verboten flag is true. Undo Prevention ends when undo verboten flag is false.

After doing something during Undo Prevention: [any successful action]
	now undo verboten flag is false;
	continue the action.

Before undoing an action during Undo Prevention:
	say "Sorry, UNDO is not allowed at the moment. You must live with your choice.";
	rule fails.

After taking the unnamed stuffed bear:
	rule succeeds. [optional; prevents "Taken."]

Naming the Bear is an irreversible choiceful scene. Naming the Bear begins when the player carries the unnamed stuffed bear. Naming the Bear ends when the player carries the named stuffed bear.

When Naming the Bear begins:
	say "Your father asks, 'What will you name the stuffed bear?[paragraph break]1.) Ignatius[line break]2.) Hippolyta[line break]".

Selecting is an action applying to one number. Understand "[number]" as selecting when a choiceful scene is happening. [an action so turn sequence is followed] 

After selecting during Naming the Bear:
	if the player's command matches "1":
		name the stuffed bear as "Ignatius";
		say "Your father says, 'Your grandfather's name! Good choice.'";
	otherwise if the player's command matches "2":
		name the stuffed bear as "Hippolyta";
		say "Your father says, 'Your grandmother's name! Good choice.'";
	otherwise:
		say "Your father frowns and says, 'You can't do anything until you name that bear that I worked so hard to pay for and gave you because I love you. Now pick 1 or 2, damnit!"
2 Likes

Yikes. That requires a ton of rewriting all my number-choosing “After reading a command” sections, of which there are many, some leading directly into other choices still in the same “After reading a command.”

So this may just not be worth it. I can see people undoing like crazy if they’re opting for a specific outcome, but that may just have to be the way it is. That code is really cool, though, and I mostly understand it, which is even cooler.

OK, this seems to work better, and would be far easier to plug into my existing system, if there aren’t any awful problems with it. I added some tracking stuff to see how that works, too, and it all seems fine.

"Bear Naming 2"

Include Undo Output Control by Erik Temple.

Lab is a room. 

Something can be named. Something is usually not named.

Every turn when the player is named:
	say "AHA!";
	showme tracknumber.
	
Tracknumber is a number that varies. Tracknumber is initially 0.
The last action is an action that varies.
	
First after doing something:
	now the last action is the current action;
	continue the action.

Before undoing an action when the player is irreversible:
	say "Sorry, UNDO is not allowed at the moment.";
	rule fails.

At the time when undoback:
	now the player is not irreversible.
	
Something can be NameChoosing. Something is usually not NameChoosing.
Something can be irreversible. Something is usually not irreversible.
The stuffed bear is here.

Father is a man in lab.

Report taking the stuffed bear:
	now the player is NameChoosing;
	undoback in one turn from now;
	now the player is irreversible;
	say "Your father asks, 'What will you name the stuffed bear?[paragraph break]1.) Ignatius[line break]2.) Hipplyta[line break]" instead.
	
After reading a command:
	if the player is NameChoosing:
		now the player is named;		
		if the player's command matches "1":
			now the player is not NameChoosing;
			increment tracknumber;
			now the printed name of the stuffed bear is "Ignatious";
			say "Your father says, 'Your grandafther's name! Good choice.'" instead;
		otherwise if the player's command matches "2":
			now the player is not NameChoosing;
			increment tracknumber;
			now the printed name of the stuffed bear is "Hippolyta";
			say "Your father says, 'Your grandmother's name! Good choice.'" instead;
		otherwise:
			say "Your father frowns and says, 'You can't do anything until you name that bear that I worked so hard to pay for and gave you because I love you. Now pick 1 or 2, damnit!" instead;
	otherwise:
		continue the action.
	

Instead of dropping the stuffed bear:
	say "Your father probably wouldn't like that.".

Can I get an opinion on the solidity/wobbliness of using this? All the places where the player is asked to make choices are actions that can’t be done twice.

I mean… it looks a little wobbly to me on general principle from a coding perspective (since it seems really wrong to put important game responses in an After reading a command rule), but you’re the one writing award-winning games!

I can’t see anything else that looks like a functional problem, unless you wanted normal turn sequence events (like time passing) to happen during the name selection.

2 Likes

Yeah, I’m going to devise any workaround I can to avoid actually learning anything about real coding. Maybe one day.

… which only exist because of the army of smart people here propping them up. There are times when I want to list “The Intfiction forum” as the author of a game.

Hooray! No, I don’t have any turn-dependent stuff in there. Thanks a million for all the help, as always.

2 Likes