Is it possible to look >into< an Extension?


the reason why I am asking this is because I use Emily Short’s “Basic Screen Effects” and I’m a heavy user of “pause the game” and clear the screen when I fire off a bunch of text. What I truly like about “pause the game” is that you do not have to press Enter/Return - just hitting the space bar will do the trick.

Now - I’d like THAT for a response system that accepts certain letters or numbers and proceeds only when an “approved” letter or number has been pressed - without the hassle of hitting enter and messing up the screen layout.

Since I have no clue, how she did it I am wondering if it is somehow possibly to look into the extension and check the source code to see how it is done so that I could copy and modify it for my purposes …

File > Open Extension > Emily Short > Basic Screen Effects will give you its source code. You can even edit it from there if you want, though that’s usually a bad idea.

However, note that this particular trick is written in I6.

And by the way, a particularly useful extension to look at is File > Open Extension > Graham Nelson > Standard Rules.

That simple, eh? I am ashamed of my self …

Looks like Gibberish but over time I might make sense of it. :slight_smile:

Thanks for the response!

Don’t edit the extension - copy the code of the phrase into your story’s code and then modify it. The compiler will use your version instead of the extension’s. Or rename it to be extra safe.

This code (for requiring a password to continue) might achieve the sort of effect you have in mind.

To decide what number is the chosen letter:
	(- VM_KeyChar() -).
To say the literal of (K - a number): 
	(- print (char) {K}; -).

To require password  (T - a text): carry out the awaiting activity with T.	
Awaiting something is an activity on texts.
Before awaiting a text: say "Type the password to continue: ".
For awaiting a text (called T):
	let c be 1;
	while c is at most the number of characters in T:
		if "[the literal of the chosen letter]" is character number c in T:
			now c is c plus 1;
			now c is 1.
After awaiting a text: say line break.

Secure Vault is a room.
When play begins: 
	require password "123abc".

Wrapping this up in a new activity isn’t necessary, of course, but it gives it some flexibility. The important bits are the two I6 definitions at the top (the first of which is cut-and-pasted from Basic Screen Effects), and the code inside the “For awaiting” rule.

I don’t know how well this will play with different keyboard encodings. I think it should be OK as long as your passwords stick to the common characters.

Oh my, that is a very useful example. Thanks. :slight_smile:

Absolutely rename it to be extra safe. I’ve encountered several hard-to-find problems where I saved a different copy of an old extension and then Inform keeps grabbing the modified copy instead of the updated versions I download.

That said, while jrb’s code will work, I don’t recommend actually taking passwords that way. Because you’re basically reimplementing “getting a line of text”, but without arrow keys, backspace, autocomplete on mobile, copy-paste, accessing previous input…

Actually, I don’t think my code does work particularly well. (I posted it in a hurry, as I was rushing for a train.)

Quite apart from arrow keys, backspace and the rest of it* one thing you’d certainly want is the ability to exit the password request (without having either to quit the interpreter, or else guess a random text string). My code doesn’t allow that.

I thought it would be trivial to add in a “exit on space”. But apparently it’s not so simple, at least not while the code is wrapped up in an activity.

The problem is getting an activity to return a value (success/fail). I think this must be possible in theory, because at least one of the built-in activities appears to do it (deciding the concealed possessions of something). But I’ve no idea how you’d code that. Perhaps I’ve missed something obvious; any ideas?

Of course, I could just abandon the activity framework and create a new rulebook producing a value. But that seems a shame; it seems me that this is something activities ought to be good for.

  • about which Draconis is quite right. I only intended it as a demonstration of the I6 inclusions, not a sensible implementation of a password check.

Except for where extensions dive into I6 (which is a good place to do it), all of them are written in the same exact language as I7. They’re a useful resource to learn all kinds of tricks!

Also, some really good authors will comment their extensions (and source text as well) explaining what everything is actually doing. Emily and Graham have example games with source-text available, and I think Ryan Veeder (among many others) comment their code really well and make it available if that’s a help for you.