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.