I7: Customizing Extension Code

I need to customize one “carry out” rule that is part of an extension which I have included in an I7 project, so that it operates slightly differently than as originally written. I tried copying the relevant “carry out” rule into my source code, and then modifying the relevant parts to achieve what I need. What happens is that, at run-time, it executes both the modified version (which operates correctly) and the unmodified version. How can I “turn off” the unmodified rule so that only my modified version is executed? I don’t want to play around with the extension itself, I just want to change its behavior in this one respect for purposes of this one project.

The rule in question is not a “named” rule, so “The blah-blah-blah rule is not listed in any rulebook” is not an option.

Thanks.

Robert Rothman

You can say that your new rule is “listed first” (see section 18.4 in the Documentation) in the relevant rulebook, then “stop the action” or whatever to prevent the old one from taking place as well.

Or – and I don’t know if this is something that only works from another extension, but you could try it – maybe you could use the “Section 6 - Hacked locking (in place of Section 1 - Regular locking in Locksmith by Emily Short)” syntax that is described in chapter 25.8, if you have an entire section of the extension to override.

Thaks, Tove. It looks like your first suggestion does the job. I need to do a little more testing to ensure that stopping the action doesn’t also turn off any critical “report” or “after” rules that relate to the action in question, but in this particular case it doesn’t look there are any.

Robert Rothman

“stop the action” will prevent report and after rulebooks from firing. You’ll need to use section replacement if you want to use the extension, or handle all reporting with your own (instead?) rules.

And write to the author, asking them to name every rule in their next release! Better yet, modify the extension and send the fixed version to the author with your request.

Would something along these lines be safe, or is it but an horrid abomination?

[code]Carry out grueing (this is the new grueing rule):
say “You’re about to eat a grue.”;
anonymously abide by the after stage rule;
consider the investigate player’s awareness after action rule;
consider the report stage rule:
rule succeeds.

The new grueing rule is listed first in the carry out grueing rulebook.[/code]

It looks pretty ugly to me, but I think it could work if you’re careful. The question is going to be, how complex is the action that you’re modifying? If it’s something fundamental like going or looking, there are going to be a lot of gotchas. But if its range of possibilities is narrow enough, you can probably get away with a single Instead rule that covers the entire action.

What I usually do is open the extension, and save it under a new name (if extension is name blah, I call it blah2). Of course changing the name on the first line and the last line (before documentation) within the extension, then I edit the new copy to create the changes I want. Also, now I still have the original for other projects, or in case I screw it up.

This way nothing needs to be changed in the game code, and the extension does the work the way you want it to without having to battle with it in the game code.

Not sure if this would work for you. But it is another way to customize extension code that I find useful.

I usually leave the name the same, but change the author to myself and update the version number. Then you don’t have to change the last line, though you may have to move the file to the extension directory with your name on it (this is done automatically when you install an extension).

I do that too. But I usually wait till I have perverted it so much, the original author would not want her/his name on it. :smiley:

Either way, I think editing the extension is better than trying to work around the things you do not like about it in the game. And then when you are done, you have a personalized version that is tailored to your own style and tastes.

Yeah, I make a copy, change the author to me, and also change the name to ‘Locksmith for (my game name here)’.

Whether or not you change the name, one thing you probably want to watch for is the fact that if someone types ‘version’ in your game, it’s gonna list you as the author of all those extensions, and the original authors’ names won’t be anywhere.

I suppose if you consider the result of typing ‘version’ to be tech info only (and technically true info generated by the game itself), and you mention the original authors and their work in your credits, that’s probably enough.

My own workaround is to add ‘authorial modesty’ to all the extensions I mutilate, so they aren’t listed automatically, then I add reporting to the version command which says ‘I used modified versions of the following extensions…’ And then I list the original names, authors and version numbers.

Now that is a good idea. I do add comments in the documentation of the extension, but no one ever sees that.

I am not sure how to add reporting to the version command, I will have to look into that. I do not want to be a thief, but I do like to borrow things. And giving proper credit in the version report would be a nice thing to do.

All you have to do is add this line to your game code:

Report requesting the story file version: say "This game also uses modified versions of the following extensions:[line break]Exit Lister version 9 by Eric Eve[line break]Put the next extension here, etc."

If a person types version when they play your game, first everything that Inform generates itself is printed out, then it prints any stuff you’ve added with this ‘Report requesting the story file version’ rule.

Thanks to all who replied. The particular action that I needed to customize has (as far as I can tell) no “report” or “after” rules, so Tove’s idea seemed like the easiest approach. In other situations, I would probably use the approach of copying the extension, customizing it and including the copy.

The suggestions for how to provide proper attribution in reponse to the “version” command are very helpful in this regard. Those who write extensions (and, for that matter, Inform itself) very generously make their work available for all to use, and I would not want to use their work without appropriate attribution. (This is something that I may be particularly sensitive to, having once been, in a totally different context, the victim of plagiarism.) At the same time, I’m always leery of attributing a work to somebody if it contains anything (even a single word) that he has not approved. (Again, my own personal experiences in other contexts may have colored my thinking here – I have had more than one experience where editors have taken an overly heavy hand to my work and have, to my way of thinking, mangled what started out as rather elegant bits of prose.) The idea of adding a specific reference which explains that the game makes use of “a modified version of Extension Whatever-it-is by Joe Blow” seems to address both of these concerns.

Robert Rothman

If you are not making substantial changes, I think it would be more respectful to leave the byline intact. Calling it out as a modified version suggests that you have invested more effort than simply fixing the bugs that arise from interactions with your code and other extensions.

I’m all for giving credit where credit is due, but I also don’t want to assign blame where it’s not due. Even if there are minor tweaks, I’d want to say so - it’s simple enough to say that the changes were minor.

Just a note that the extensions at inform7.com are licensed with Creative Commons Attribution license. It means that the original author must be credited somewhere in the game even if you’ve made substantial changes to the extension, so it’s not just a matter of common courtesy.

(Strictly speaking even extension authors who use the authorial modesty option should be credited, but perhaps it’s considered that the authors have waivered their rights in these cases.)

Perfect. I just added a similar line to every extension I have renamed and modified, or even just used small parts of someone elses code, to add into my extension(s). Thanks, now my conscience is clear.

What should I do in the case where I’ve modified an extension that is a modification of another extension?

Okay, I have to admit, that made me laugh. You add another layer to the mix.

I would say give both authors credit, in order of first author, then first modification author, at least that is what I would do.

Could we define a protocol for the way this is done? If this is a matter of complying with the Creative Commons license, it seems like every extension with multiple authors should follow the same format, so the “version” output looks consistent.

Ideally the protocol should be in the documentation. Better yet, add some kind of Table of Previous Authors that gets formatted the right way automatically.