I wrote an extension. Now what?

I wrote an extension to compress some of my boilerplate code. Now what? I can’t run it. The buttons at the top of the IDE are greyed out. I can save it to my personal library and it works within my program (I think). What is the difference between an extension (.i7x file) and an extension project (.i7xp)?

I tried making a fake project to place my extension into, but that didn’t work. I think the IDE knows the difference between a .inform file and a .i7xp file.

btw, the Inform 7 docs do not help with this.
Any help would be apprecitaed

2 Likes

Now you can use it in as many projects as you like! Just include it at the beginning of the main project file:

Include My Shiny New Extension by John Doe.

And, if you post it here or on Github, other people can download it and use it in the same way.

2 Likes

Thanks for this, but how can I test it. What are the answers to my other questions about running it by itself, and the file types?

1 Like

If it works for your purposes, that’s your test. Not every extension has to be useful to other people. I had a personal extension I created for my own shortcuts for text formatting.

.i7x is the extension that Inform recognizes to import into your library and invoke with Include My Shiny New Extension by John Doe.

I’m not quite sure what the extension project is used for exactly. I think it was just a way to have an IDE file template to start you off with the “here begins the official extension called…” boilerplate when you’re making it in Inform 7.

Extensions won’t run by themselves, usually since most are designed without a world-model implemented. They’re meant to be pulled into an Inform7 game. An extension isn’t much except external code. In fact, you can copy the text of an extension into your source (minus the “here begins/ends XXX by XXX” lines) and it will work as if you had written that code (except it won’t credit the extension). It’s a shortcut, not a running game.

Once you have it as an .i7x, you can tell inform through the IDE to import it, or you can open that extension and there’s a button to import to your library. Once that’s done, you just call it with “Include…”

2 Likes

The special feature of an extension project is that when the extension includes examples, you should be able to compile any of the examples from that one project via a handily-supplied menu that appears in the IDE.

e.g. The extension project is for an extension called “Super Combat”. This extension includes two examples you’ve made, one called Swordfighting and another called Polefighting. With the Super Combat extension project loaded in your IDE, you SHOULD get a menu somewhere at the top of the IDE (in or around the TEST button) that will let you build and test either Swordfighting or Polefighting in the Story tab.

Especially while still tweaking the extension, this is way less hassle than having to write the extension, stick it in the Extensions folder, dig up the code for Swordfighting, put it in a new Inform project and build it there. Then go and build another project for Polefighting. And then keep jumping back to the extension to edit it during the process.

Now the reason I said SHOULD a couple of times above is that this feature of extension projects wasn’t working neatly last time I looked or tried it. I had trouble getting the examples menu to appear. The feature was pickier with the naming of the files and examples than usual. And I forget whether there was more trouble beyond that.

If your extension is just for you and has no examples, there’s not much to be gained by writing the extension in an extension project.

-Wade

5 Likes

Wade,
Thanks for this. I’m not sure I understood everything about examples and menus but it helped. It certainly doesn’t pop up on my IDE.

All I want to do is put some testing inside my extension instead of inside my story. Doesn’t work. These extensions seem less like a library function than merely a link to story code. Barely worth the effort for personal use.

1 Like

As Wade said, the IDE can be finicky regarding the exact format needed to make the extension’s tests/examples playable.

At least in I7 6M62, it should work like this: Start a new extension project, enter your code between the “begins here” and “ends here” markers, then add the line “---- DOCUMENTATION ----” surrounded by a blank line above and below, then add an example for testing, following this pattern:

Example: * YourExampleTitle

	*: "YourExampleTitle"

	Include YourExtensionName by Falsoon2.

	The Lab is a room. [Any room name will do, of course.]

	Test me with "<some commands to test your extension>".

The indentation has to be correct, one tab as above. The number of stars can vary, they indicate how difficult the example is intended to be, which doesn’t matter for internal use, of course.

The IDE should display a “Test” button to the right of the “Go” button when you have the project open as an extension project (.i7xp). When you click the Test button, the compiler will compile the example, including your extension, and run through the list of “Test me with …” commands, and inform you about the outcome of the tests. You can test it further by hand in the Story tab, as usual.

So, just as an example, here’s a toy extension with an included test. If you copy this into a new extension project, it should work as described above.

Duels by StJohn Limbo begins here.

Challenging is an action applying to one thing.

A person can be challenged or neutral.

Understand "challenge [someone]" as challenging.

Carry out challenging:
	now the noun is challenged.

Report challenging:
	say "[The noun] accepts your challenge." 

Duels ends here.

---- DOCUMENTATION ----

This extension implements duelling (not really).

Example: * Pushkin

	*: "Pushkin"

	Include Duels by StJohn Limbo.

	Saint Petersburg is a room.

	The insulting letter is a thing in Saint Petersburg.

	Pushkin is a man in Saint Petersburg.

	Test me with "challenge letter/challenge pushkin".

The IDE should look like this with an extension project:
grafik

4 Likes

I think I found a bug in your example – shouldn’t Pushkin be the one sending the letter?

(I am usually positively disposed towards poets, but from what I’ve read about him it sorta seems like Pushkin was a schmuck)

1 Like

He did, the player is intended to be d’Anthès who has just received Pushkin’s insulting letter and now has to challenge him. (For brevity, I omitted descriptions and put him in the same “room”.) :slight_smile:

2 Likes

Thank you. This is perfect, exactly what I need. And thanks for the screen shot of the IDE when an extension is “on”.

1 Like

StJohn,
I had trouble getting this extension with example to work, so I cut-n-pasted it directly into a new extension project, except that I changed the name to “Duals by Clyde Falsoon” and adjusted the ‘begins here’ and ‘ends here’ statements. I saved it, I installed it, it did nothing, and I never saw the IDE with a test option. I am running Version 1.68 on a Mac. What am I doing wrong? Also, the documentation does not appear on the extension library by the name.

btw, I have a couple personal failed extensions that I would like to delete. How do I uninstall an extension? Merely delete it from my extensions file in the folders?

The IDE should display this option even with a blank new extension project.

You can start a new extension project from the File menu under File → New Extension Project [not “New Project” or “New Extension”!] → New Extension.

grafik

Inform will prompt you for the location and name, and will create a new extension project with a source pane which is blank except for the “begins” and “ends” lines.

For me, if I do the steps above and call it “SomeName”, this is what the IDE will show then:

grafik

I’m using the IDE on Windows, so I don’t know whether it’s different on the Mac, unfortunately.

StJohn,
Windows vs Mac. That explains a lot. I did all that you suggested in building my extension. All that worked ok, but I never see the Test button enabled.

My menus are different for the IDE too. You have a list of menu options at the top of the Extension that do not appear for me; my menu options are on the main frame of the IDE, nothing in the extension IDE. That could be explained by a platform difference.

The extensions work inside my program/story file but I just want to be able to test them before Including them. Your solution seems like it would work, but it doesn’t on my Mac. I’ll look around for some Mac-insufficiencies posted somewhere.

My screenshots above are also from the main frame of the IDE, but just showing an extension project instead of a normal project. (And the “Source”, “Results”, “Skein”, … panel choice tabs are at the top, because the Windows IDE lets you choose whether you want them horizontally above the panel, or vertically along the middle divider.)

The main IDE view of an extension project is different from the IDE window which shows an extension by itself, at least in the Windows IDE.

Here’s the main frame of the IDE showing an extension project (with Test button etc.):

Here’s the IDE showing the extension in a separate window (with different menu and different background colour):

Maybe you can post some screenshots from the Mac IDE, because I think the IDEs are generally aiming for feature parity, so it could be worth opening a bug report if something doesn’t seem to be working correctly.

Good idea. Here is a screen shot of the source side of the IDE. Note that there are no menus at the top. The menus are only Inform level menus in my toolbar at top. I suspect that Mac OS Monterrey is the culprit in that it is a 64-bit platform that Inform developers haven’t caught up with yet.

Hello @Falsoon2

I’m working on macOS and am new to authoring and testing extensions.

The issue here is that your source doesn’t compile. I typed out most of your example and ended up with the following:

This error is pointing to the fact that your code has a line that looks like this:

say [mission of HQ]

But you don’t define mission of HQ in your code. In other words, you’re trying to reference an undefined variable (in programmer-speak).

A Revised Example

After commenting the line say [mission of HQ] and making a few alterations, I can test this extension on macOS.

Here’s the revised source text I tested:

Version 1.0.0 of Name Collection by Clyde Falsoon begins here.

The default command prompt is text that varies.

When play begins:
	now the command prompt is "What is your full name, soldier?   ".
	
The player's forename is a text that varies.
The player's last name is a text that varies.
The player's full name is a text that varies.
The player's full name is "An anonymous tester".

To decide whether collecting names:
	if the command prompt is "What is your full name, soldier?   ", yes;
	if the number of characters in the player's forename > 1, no;
	no.
	
After reading a command when collecting names:
	if the number of words in the player's command is 1:
		say "[paragraph break]Who do you think you are? Madonna? Prince? Cher? Jesus? Maybe you are famous enough to be known by a single name. I'll give you the benefit of the doubt.";
		now the player's full name is the player's command;
		now the player's forename is word number 1 in the player's command;
	if the number of words in the player's command is 2:
		now the player's full name is the player's command;
		now the player's forename is word number 1 in the player's command;
		now the player's last name is word number 2 in the player's command;
		[say "[mission of HQ]";]
	if the number of words in the player's command is 3:
		now the player's full name is the player's command;
		now the player's forename is word number 1 in the player's command;
		now the player's last name is word number 3 in the player's command;
	if the number of words in the player's command is greater than 3:
		say "Who are you, a member of the British royal family? No one has that many names. Let's try this again.";
		reject the player's command;
	now the command prompt is "> ".		
Name Collection ends here.

---- DOCUMENTATION ----

This extension collects the first and last name of the player for later reference.

Example: * One-Part Name Collection Test

	*: "One-Part Name Collection Test"
	
	Include Name Collection by Clyde Falsoon.
	
	Test Center is a region.
	
	Test Suite A is a room in Test Center.
	Test Suite B is a room in Test Center.
	Test Suite B is north of Test Suite A.
	
	The description of Test Suite A is "[player's full name] stands alone in Test Suite A."
	
	The description of Test Suite B is "[player's forename] [if number of characters in player's last name > 0][player's last name] [end if]stands alone in Test Suite B."
	
	Test me with " north / Danya".
	
Example: * Two-Part Name Collection Test

	*: "Two-Part Name Collection Test"
	
	Include Name Collection by Clyde Falsoon.
	
	Test Center is a region.
	
	Test Suite A is a room in Test Center.
	Test Suite B is a room in Test Center.
	Test Suite B is north of Test Suite A.
	
	The description of Test Suite A is "[player's full name] stands alone in Test Suite A."
	
	The description of Test Suite B is "[player's forename] [if number of characters in player's last name > 0][player's last name] [end if]stands alone in Test Suite B."
	
	Test me with " south / north / Danya Smith".
	
Example: * Three-Part Name Collection Test

	*: "Three-Part Name Collection Test"
	
	Include Name Collection by Clyde Falsoon.
	
	Test Center is a region.
	
	Test Suite A is a room in Test Center.
	Test Suite B is a room in Test Center.
	Test Suite B is north of Test Suite A.
	
	The description of Test Suite A is "[player's full name] stands alone in Test Suite A."
	
	The description of Test Suite B is "[player's forename] [if number of characters in player's last name > 0][player's last name] [end if]stands alone in Test Suite B."
	
	Test me with " south / north / Danya D. Smith".
	
Example: * Four-Part Name Collection Test

	*: "Four-Part Name Collection Test"
	
	Include Name Collection by Clyde Falsoon.
	
	Test Center is a region.
	
	Test Suite A is a room in Test Center.
	Test Suite B is a room in Test Center.
	Test Suite B is north of Test Suite A.
	
	The description of Test Suite A is "[player's full name] stands alone in Test Suite A."
	
	The description of Test Suite B is "[player's forename] [if number of characters in player's last name > 0][player's last name] [end if]stands alone in Test Suite B."
	
	Test me with " south / north / Danya Danine Smith / Danya Danine Robinson Smith".

A few lessons learned:

  • If you don’t have a working test in the source, the Test button will remain disabled.
  • If your source text does not compile, the Test button will remain disabled.
  • If there is at least one working test, you should be able to select it in the dropdown and click Go!
  • The Go! button allows you to playthrough a test the same way you can playthrough a story
  • The Test button executes a test and compares the output to the Blessed version (if one exists)

One weird thing I still don’t understand…

Test me with wants me to type all commands in reverse order. Is this expected behavior?

One other thing I need to research…

How to suppress That's not a verb I recognize. in response to the player’s input.

2 Likes

Thank you for spending so much effort on this problem. I found out that there is a confirmed bug in the Mac version. Inform 10 is needed for Mac Monterrey (64-bit system) and it has been recorded. There are many lines of my source code that needs to be revised from I7, which was working, when I switched to I10-andnot just for the extensions either. The extensions problem has been resolved.
Thanks.

Good to hear!

I didn’t mind spending time on it. If you didn’t share it, I would have missed out on an opportunity to learn.

I’m glad you got to the root of the issue.

For cross-referencing purposes, here’s the other thread where we talked about the extension issues on the Mac: Mac vs Windows extension building

Hmm, that’s strange, shouldn’t happen that way. It doesn’t occur for me on Windows Inform7 v10.1.2. Can you reproduce the circumstances? Is it always the case, even with “TEST ME” in a normal story that’s not an extension project?

That’s printed because, after storing the player’s input in the name variables during the “After reading a command” rule as implemented above, Inform’s normal input processing continues, and it thinks it should process the input “Danya” as a normal verb/command, which it doesn’t recognize.

To stop Inform from doing that, you need to “reject the player’s command” not just in the case of invalid name input, but also in the case where the name was successfully stored. (It may sound a bit counterintuitive to “reject” valid input, but at that point, we already did what we wanted to do with it, and just want to tell Inform not to continue processing the input as an action.)

So, you’d add that rejection at the end of the rule, after resetting the prompt:

After reading a command when collecting names:

	[...]

	now the command prompt is "> ";
	reject the player's command.

For comparison, the original example is “Identity Theft”, cf. Recipe Book 5.2. Traits Determined By the Player.

2 Likes

No, it only happens in an extension project.

But yes, it is always the case.

I’m using Inform 1.83.3 on macOS with the current version of Inform 7. I’m assuming that’s 10.1.2, but when I go into settings to select the Language Version, my options are:

  • Current
  • Inform 10.1, August 2022
  • Inform 9.3 (6M62), December 2015
  • Inform 9.2 (6L38), August 2014
  • Inform 9.1 (6L02), May 2014

…so I can’t see the current version number.

1 Like