Disallowing UNDO selectively for only a few commands

Hey All–

I have a few places in my project where UNDO would cause problems, so I want to disallow UNDO for only a few commands. I found this thread (squeal fangirl the OP is Michael Gentry OMG) and located Erik Temple’s Undo Output Control, but I confess I’m having a hard time understanding how to implement the “Suspend Undo” section. How/when do I use the terms “suspend undo” and “reinstate undo” when the player can undo over several turns? I only have about 5 actions that must not be undone, so these need to be completely ignored by UNDO no matter how far back the player tries to go.

I just don’t understand how this extension works. Can someone smart splain this to me?

Edit: I can’t even figure out how to copy/paste the code into my project. Are all these “Perform_Undo” bits of code different versions of the same thing? I’ve never been able to get an extension loaded into Inform, so I just copy/paste the code.

2 Likes

You would only need to include the one “for use without Conditional Undo by Jesse McGrew”.

Are you willing to disallow multiple UNDOs in a row? If I understand things correctly (and this is an area I haven’t dug into, so I may not), Undo Output Control would make what you want straightforward with a single-turn limit, but for multiple turns, we’re suddenly talking about storing state in an external file or using Glulx protected memory.

1 Like

I don’t know. I don’t care about anything except that these few actions are not undoable, ever. Would disallowing multiple UNDOs be annoying? The game doesn’t let you screw up (at least, hopefully), so theoretically you shouldn’t need multiple UNDOs, but I have rightfully been accused of nannying behavior before, so I’m suspicious of doing something like that and ticking players off.

The following would be a way to forbid undoing of certain actions which we can group under a kind of action, such as “irreversible behaviour”:

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 last action is irreversible behaviour:
	say "Sorry, UNDO is not allowed at the moment.";
	rule fails.

The Lab is a room.

The radioactive element is in the Lab. The description is "Better not take it.".

The vial is in the Lab. The description is "Handle with care."

The block attacking rule does nothing when attacking the vial.	

Carry out attacking the vial:
	say "The vial shatters.";
	remove the vial from play;

The apple is an edible thing in the Lab. The description is "Might be poisonous."

Attacking the vial is irreversible behaviour. Eating the apple is irreversible behaviour.

(Taking the element can be undone, for testing purposes.)

(One can undo multiple turns, but what this approach doesn’t do is to leave the irreversible commands out of the record. So the player can’t: do 1, 2, 3, where 2 is irreversible, and then undo twice to undo only 3 and 1. The undoing will stop at 2.)

4 Likes

The extension docs are pretty thorough, what’s left is a means of testing the condition “was the most recent action one of the not undoable action?”

I know you prefer to hammer out the details yourself and I don’t have a 9.3 compiler handy anyway, so I think you’d want something like this untested code.

Assuming none of the actions in question are out of world actions…

most-recent-action is an action that varies.
first after doing anything: now most-recent action is the current action; continue the action. [edited after the fact...]

And a way to group together the not-undo-able actions.

Thinking is no-backsies.
Jumping is no-backsies.

Then follow the extension’s “I Love the Sound of Breaking Glass” example regarding setting up a 1-turn undo limit.

And add a rule like:

last before undoing an action when the most recent action is no-backsies:
  say "Some things can't be undone.";
  rule fails.

And I think that might do it.

Edited:

That sounds right, so you could skip the 1-turn limit stuff from “I Love the Sound of Breaking Glass”.

Re-edited: Wow! I spelled “most recent action” a different way every time!

3 Likes

What if I want an action applying to only one object to be no backsies? Like, generally inserting something into something else is fine, but inserting the electrode into the pickled brain is the action I want to trigger undo prevention?

Inserting the electrode into the pickled brain is no-backsies.

doesn’t work. I get the “appears to say two things are the same” error message.

Just to throw out a wild idea (sounds like the others have some great technical ideas), depending on the effect you’re going for, you could use the ‘writing to a file’ trick and keep a table there of key decisions.

For instance, Eat Me lets you eat the child corpses at the beginning but doesn’t let you UNDO it (this doesn’t use the feature I’m proposing, I’m just putting it as an example). So you could have a variable like ‘ateachild’ and write that to the table as ‘true’.

Then every turn you can check if the current game state of that flag matches the written file. If it doesn’t, the game prints an ominous message and then sets the flag to what it should be.

This would actually prevent the player from undoing both through SAVE/LOAD and restarting as well. Kind of like Undertale. I think writing to a file works on the website version as well, but probably won’t be restored across sessions, but ending a session removes UNDO ability anyway.

2 Likes

Also, this is contingent on me getting the extension into my program, right?

1 Like

Move the assertions that create the electrode and the pickled brain above the Inserting it into.

2 Likes

yup, either through an actual include statement or copy-pasting it (and customizing your version command to give credit…)

2 Likes

OK, then it’s time for learning how to install an extension, since copy/pasting yielded a million screaming error messages. The documentation says, “In fact, though, Inform can automatically install extensions for us: we need only select the “Install Extension…” item on the File menu.”

Handy! Except when I choose the “Install Extension” item, nothing, and I mean absolutely nothing, happens. And that was the extent of my attempting to install extensions, since every other resource I found was in Sanskrit.

Zed has offered to teach me how to do this (everyone’s eyes are widening now as they contemplate Zed’s sanity), so get your popcorn ready, people. There will be a staggering level of ineptitude on display.

Labyrinth of Ghosts.gblorb (595.9 KB)

I know you already have a solution, but I’m proud of how this turned out so I wanted to put it here. This is modified heavily from the Emily Short example of the same name, but the idea is that you pick up the rock and drop it, and after that, you can never move it again, even if you undo, save/load, or restart the game. I’m actually having a bit of trouble thoroughly testing it because I’m not sure how to ever let someone undo this. I’d probably add some code that wipes all data clean when restarting.

Code
"Labyrinth of Ghosts"

Release along with a website and an interpreter.

Rightplace is east from leftplace.

The rock is a  thing in rightplace.

Important-flag is a kind of value. The important-flags are rock-flag.

Table of Irreversible Things
fated value
an important-flag
with 5 blank rows.

The File of Ghosts is called "ghosts".

After dropping the rock:
	say "You drop the rock. This is irreversible!";
	choose a blank row in the Table of Irreversible Things;
	now the fated value entry is rock-flag;
	write the File of Ghosts from the Table of Irreversible Things;

Before taking the rock:
	if the File of Ghosts exists, read File of Ghosts into the Table of Irreversible Things;
	if there is a fated value of rock-flag in the table of irreversible things:
		say "You can never move the rock again!" instead;
1 Like

It’s not that bad. Really.

What’s your OS? and you’re on 6M62, right? (I’m going to take a stab at describing it without the answers, but in case there are follow-up questions…) I’m not going to try to help you do it in the IDE 'cause that’s what has been giving you problems (and I’m not familiar with 'em anyway). So I’m going to describe a process which, while it’s a little tedious, should be completely effective.

In the IDE, create an Inform project. Let’s say it’s called “I Love Extensions”.

Open whatever File browser application you use. If you’re on windows, go to “My Documents” and you’ll see a directory called “Inform”; go into that directory. (I think it’s a directory called “Inform” directly under your home directory on a Mac. If you don’t see it, use the File browser application’s search to look for a directory called “Inform”.)

Once there, you should see, for all of your past Inform projects, a .inform directory and a .materials directory, including:

  • I Love Extensions.inform
  • I Love Extensions.materials

Enter I Love Extensions.materials. There’s probably already a directory called “Extensions”. If there isn’t, create one. Enter the “Extensions” directory. To minimize complications, let’s go for a short pure-Inform 7 extension to start with. So create a directory under “Extensions” called “David A Wheeler”.

In your web browser, go to Dice by David A Wheeler. Do whatever you do in your browser to “Save file as…”
And save it as “I Love Extensions.materials/Extensions/David A Wheeler/Dice.i7x”. In your file browser application, verify that it’s there.

Then in the IDE, edit the story file…

Include Dice by David A Wheeler.

Lab is a room.

when play begins: say "3d6: [3 d 6].".

And then compile it, which should actually work.

Then try creating an “Erik Temple” directory under “I Love Extensions.materials/Extensions”. If you go to the Friends of I7 9.3 extension directory you can follow the link for Undo Output Control by Erik Temple. Don’t try to save the page that lands you on; click the “Raw” button near the upper right of the source code. Then save that page as “I Love Extensions.materials/Extensions/Erik Temple/Undo Output Control.i7x”.

Then give it a spin.

3 Likes

OK, first dumb roadblock.

I am on Mac. What’s the “home directory”? I thought maybe it was the apple in the corner, but that’s not it. I searched under Applications in “Finder” and didn’t see Inform, which weirds me out because I have Inform and it’s open.

And is 6M62 the regular old Inform? Because this project is under the old one. I still haven’t tried the new one because learning is hard and change is hard.

Edit: I found it, I think. But it doesn’t have anything in it.

screenshot

I searched under Applications in “Finder” and didn’t see Inform

I was afraid this step could go awry. “home directory” isn’t a Mac OS term. If you know where your other applications store files you create, go to the directory above that directory (and keep going for a couple of levels, why not) to see if you see an “Inform” directory.

[ edited: actually, even better, look for a file called “story.ni”. There should be a multitude of those in folders called “Source” which in turn are in folders whose names end “.inform”, and alongside those .inform folders should be I Love Extensions.inform and its material friend. ]

If that’s fruitless, unless a Mac person comes along with better advice, search for a directory called “Inform” on the whole darn computer. Not as an application, just a folder called “Inform”.

Yes, 6M62 is regular old Inform.

I suspect you found some Home automation application.

1 Like

You are SO regretting this already.

I can never find anything with Finder. I literally never use it because it has never once found anything I was looking for. I search for “Inform” and it brings up hundreds if not thousands of results, none of which appear to be Inform, although if I have to go through thousands of results, I’m not sure why Finder is even there.

I think we all already know that I do not know where any files are, other than the ones I keep on my desktop.

Maybe try starting a new Inform project, saving it with a unique name, then search for that to see if you can find the directory that way?

(I know nothing of Macs, if that wasn’t already clear)

1 Like

The internet suggests that, in the Finder, opening the Go menu and picking Home will get you your home folder?

1 Like

I suspect it’s looking for “Inform” in files’ contents, rather than for directories named Inform. My extremely vague understanding is that there should be a dropdown menu when you start tying in the search box that should allow you to select Filename contains "story.ni".

Not your fault. Mac OS’ ethos is that things should just work™ and to not let us worry our pretty little heads about the little details that might give us half a chance when they don’t. (Hmm. I’m reminded of Inform’s stance toward Inform 6 inclusions.)

1 Like

Oho. I think I have found it. It was, like all things I use, under “Desktop”.

Let’s see if I can progress with your directions.

Isn’t this fun?

2 Likes