[too tricky] I7: alternate undo prevention w/o an extension?

I wanted to make a simple change to the “can’t undo” message to make it more user-friendly and relevant to my game, e.g. “This is pretty much a 1-move, 1-room game with a random solution. Undoing would sort of break it.”

However, I wasn’t able to find a way to do so without using an extension. And I want to avoid that, if possible.

[code]“easy-undoes-it” by Andrew

use undo prevention.

room 1 is a room.

[test with l.undo]
[/code]

This would do the job, and the following does what I want, too, just not succinctly.

"easy-undoes-it" by Andrew

include Conditional Undo by Jesse McGrew.

room 1 is a room.

Rule for deciding whether to allow undo:
	say "It wouldn't be fair to allow undoing here, since you're only supposed to get one guess at the right answer.";
	decide yes;

This is more than adequate, but I’d rather not include an extension if I don’t have to.

I’ve also tried the following, but it ignores my new verb, and I’m not sure why.

[code]room 1 is a room.

undoing is an action out of world. understand the command “undo” as something new. understand “undo” as undoing.

carry out undoing:
say “It wouldn’t be fair to allow undoing here, since you’re only supposed to get one guess at the right answer.”
[/code]

Also the rather cheap looking

after reading a command: if player's command includes "undo": say "Oops, different undo message."; reject the player's command;

…doesn’t work.

Is there any way I can do things without an extension or is UNDO too ingrained in the Inform core to do anything? Nothing popped up when I tried to RULES before UNDO, either.

This is more general wondering than an actual brick wall, so, thanks again for any suggestions!

The UNDO command is processed before any parsing happens (as is OOPS), essentially in the same routine that reads in the command, so there is no way to do this without an extension, or without hacking the library code yourself. But why would you want to avoid using extensions anyway?

–Erik

Well, I wanted to have something that could fit in a Z5 file (just for its own sake,) so I was thinking if I could get away with no extension, great–that much more space.

And I do love having the extensions there and using them and finding someone’s already done a better job with supporting code than what I could’ve done by myself. It’s just that this seemed like the sort of thing I maybe should know, if it was available. I’m still striking a balance between being able to rely on them and worrying I’ll depend on them when I don’t need the whole thing (e.g. might make a project too bulky.)

Hacking the actual library code’s beyond me (I’m able to look through extension code to learn roughly what it does and how, which is neat but it’s my limit,) but I’m still at the stage of learning Inform 7 where I realize I might be missing something easy and elegant, so I wanted to check off on that.

Thanks for the quick response!

I see. There may be one misconception here: Adding an extension doesn’t necessarily mean increasing the size of your game file. If all the extension does is replace sections of the library code with tweaked versions, for example, that would likely add nothing to the file size, and might even subtract (if the extension primarily removes functionality, for example.)

I think you can rest easy on the memory front where the Conditional Undo extension is concerned. It is mostly just a change to the library code, that essentially would add nothing to your game file. Conditional Undo does add at least one activity, I believe, but that’s not really any more than you would add yourself if you were writing your own rule to prevent undo.

–Erik

If you wanted to be really tight about it, you could look at the extension source code and copy the bits you wanted into your code. It’s just code.

Those are two good ideas. Thanks. I have to confess I only have so much knowledge of the nuts and bolts of compilers–and even when that sort of thing probably won’t help me write a better story, I’m still curious.

And I agree that what’s there works well–both extensions.