What are best practices for modifying extensions in Inform 7?

0 votes
89 views
asked Apr 13 in Authoring by bg (692 points)

If someone else's I7 extension doesn't do quite what you want, are you usually better off modifying the extension file itself, or leaving it as-is and making changes via the code of the game? And if it's the latter, are there other ways to make the changes besides these:

  • Individual rules in the extension, if they are named, can be referred to in the game, so you could say "The fancy title banner rule does nothing" or you could create your own rule and say it substitutes for the original rule, as in §19.5 of Writing with Inform.
  • A text response with a letter can be changed as in §14.11 of Writing with Inform.
  • Tables can be amended as in §16.19 of Writing with Inform.

And maybe there are other ways to make amendments (substituting or disabling an entire section of code, for instance?).

2 Answers

+1 vote
answered Apr 14 by Ryan Veeder (290 points)

Modifying the extension file is a bit messy, because now you have this modified file hanging around your hard drive, and those modifications might propagate to future projects in unforeseen ways. When I've needed to make drastic changes to an extension, I've forgone the "Include Extension Name by Extension Author" declaration and simply pasted the (modified) extension source into my project.

Of course, this is basically plagiarism—copying and pasting the extension, except deleting the part where the author gets credited. A jerk move! But there is a workaround for giving extension authors their due:

Report requesting the story file version:
    say "Plus modified versions of:[line break]Extension Name version X by Extension Author[line break]".

If you add something like this to the story file version text, you give all the credit that would automatically have been given if you really had included the extension—plus you have the caveat that the extension has not been implemented in its original form, which some authors might appreciate.

I would be remiss (albeit in a delightfully ironic fashion) if I did not mention that I stole this trick from Emily Boegheim.

+1 vote
answered Apr 18 by Juhana (246 points)

Here are the options available for modifying an extension, ordered from most to least preferred.

  1. Follow instructions in the extension's documentation
  2. Replace messages using the responses system
  3. Add, remove or replace rules
  4. Replace chapters
  5. Modify the extension directly

Try a solution lower on the list only if none of the ones above it don't work or don't apply. Modifying the extension directly should be the absolute last resort.

As an example let's look at a simple extension.

Version 1 of Greeter by Random Q Hacker begins here.

"Automatically greeting the player when the story begins."

Chapter 1 - Use Options

Use excessive enthusiasm translates as (- Constant GREETER_ENTHUSIASM; -). 

Chapter 2 - Greeting

When play begins (this is the welcome the player rule):
    say "Welcome! Have fun!" (A);
    if the excessive enthusiasm option is active:
        say "I'M SO PSYCHED!!!!!1!!" (B).

Greeter ends here.


---- DOCUMENTATION ----

Add "use excessive enthusiasm" to your source text 
to get really enthusiastic greetings.

1. Follow instructions in the extension's documentation

Extensions ofter provide ways to modify their own behavior. Use these mechanisms whenever they’re available. In our example extension there’s a use option to change the mood of the default messages.

2. Replace messages using the responses system

From Inform release 6L02 on you can change default messages using the responses system (manual ch. 14.10.) This is the preferred way to modify what the extension prints out to the player, but it requires that the extension author has named the rules and strings so that they can be replaced.

In the example extension, if you wanted to replace the default messages you’d do:

The welcome the player rule response (A) is "Nice to see you!"
The welcome the player rule response (B) is "Super awesome!"

The >RESPONSES testing command can list all the default messages that can be changed in an extension (manual ch. 14.12.)

3. Add, remove or replace rules

If you need to modify something other than printed messages, you can replace or remove the extension’s rules (manual ch. 19.5.)

Removing rules completely:

The welcome the player rule does nothing.

Removing rules conditionally:

The welcome the player rule does nothing if the player’s name is "Bob".

Substituting rules:

This is the new welcome rule:
    say "Hi there!"

The new welcome rule substitutes for the welcome the player rule.

If the rules are part of a rulebook you can add more rules to it (manual ch. 19.)

4. Replace chapters

For bigger changes you can replace chapters and sections altogether (manual ch. 27.9.):

Chapter 4 - New greeting (in place of Chapter 2 - Greeting in Greeter by Random Q Hacker)

This will effectively make the compiler ignore Chapter 2 in the original extension.

5. Modify the extension directly

If none of the above work, the last resort is to make a copy of the extension and modify it directly.

If you do this note that you must credit the original author of the extension, and it is preferred that you make a note that you have made modifications. Especially if you’re publishing the modified extension then crediting the author is not only basic manners but a requirement in the Creative Commons license that most extensions use.

The preferred way to provide credits in modified extensions is to add a third paragraph in the beginning of the extension, below the extension description, that is automatically printed when the extension is listed in the >VERSION info.

Version 2 of Greeter by Angela Author begins here.

"Automatically greeting the player when the story begins."

"based on the original extension by Random Q Hacker"
commented Apr 18 by bg (692 points)
Thanks! Since you mention noting that an extension has been modified--should that also be noted if you're using methods 1-4? How would you note that if you're not making a copy of the extension? (Hmm. Maybe I should have made this a separate question?)
commented Apr 18 by Juhana (246 points)
No, because you aren't modifying the extension itself, only its behavior.
commented May 22 by Dannii (329 points)
If you aren't going to publish the modified extension yourself, but are just putting it in the .Materials/Extensions folder, then don't bother renaming it, just make the change and keep the old author.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...