Rewriting the can't take people's possessions rule

[rant]First, I’d like to revive the discussion of how to bypass standard libary check rules without using procedural rules, mentioning my earlier suggestion that there be a “replace rule” button that pastes the original source text of the rule into your source so you can edit it.

Even better than a “replace rule” might be a new mechanism for exiting rulebooks. Instead of “rule fails” or “rule succeeds” or “stop the action” or “continue the action,” there could be some kind of “stop processing the check [action] rulebook” or “allow the action” statement that causes control to skip directly to the carry out rulebook. Possibly even more simply, have “rule succeeds” do the same thing - exit the current rulebook but not stop processing of other rulebooks.[/rant]

Here I replaced the rule manually after looking it up in the Standard Rules. But this one looks a bit complicated and I’m not sure what all of it is supposed to do:

Check an actor taking (this is the can't take people's possessions rule): let the local ceiling be the common ancestor of the actor with the noun; let H be the not-counting-parts holder of the noun; while H is not nothing and H is not the local ceiling: if H is a person, stop the action with library message taking action number 6 for H; let H be the not-counting-parts holder of H;

First of all, what does the “not-counting-parts holder” mean? Does that mean if the holder is a part then we walk up the tree to the owner of the part?

Second, what the heck does the last line of this rule do? The library message has already been printed and H is about to go out of scope. (right?) So I would predict that it would have no effect at all. What’s it there for?

Basically right.

Looking at the code, I see it’s a little more complicated. It does a part-walk on the object, finds the parent, and then does a part-walk on that. So if you have a drawer which is part of a desk, and inside the drawer is a pencil, and an eraser is part of the pencil… then the desk is the not-counting-parts holder of the eraser.

The last line is meaningful because it’s inside a while loop. That loop walks up the tree using the not-counting-parts operator until it reaches a person (or the room). It exits when it finds a person, but if not, it jumps another level outward and tries again.

I don’t think so; it’s not under the scope of “if H is a person,” only under the “while” loop. “If H is a person” the action stops, which I think means the whole rule stops – if you hit “stop the action” in a check rule it stops running the check rule. (I only say that because I know the loop should terminate there.) So the last line triggers when H is not a person, and resets H to whatever the not-counting-parts holder of the old H is; then, since you’ve hit the end of the “while” block, it starts over again, with the new H. So the last line is the mechanism for jumping you out another level, as zarf put it.

(Is that right?)

Yet again, I was missing the obvious. Now back to the rant…

This looks like a situation where it would be nice to have some sort of callback mechanism - we want to keep this rule, but just modify the second-to-last line. We might change it to “Follow the possessiveness rules for H”, or something like that.

True, a customization hook there would be nice. However, the model for setting it would take some work, Maybe you set up a global variable somewhere, or make it a property of the rule in some sense. (Or you have a full “every line of code is a rulebook” model, but we’re not there yet…)

On the third hand, it’s only a half-dozen lines of code to replace.

I haven’t thought about this particular example enough to offer a thought as to whether passing H to a parametrized rulebook is enough, or if Zarf is right that you’d also need a global variable, but I did want to comment more generally that this falls within the realm of things you can do now. I actually mean that in two senses:

One: You can replace the can’t take people’s possessions rule in your story file without doing any direct hacking of the library.

Two: Since the rules can so easily be replaced (and phrases even more easily), there’s no real need for this enhancement (or other instances you’ve mentioned) to be incorporated into the standard library. How about compiling an extension that acts as a grab-bag of such tweaks, providing appropriate default behavior, etc., and share it with the community? There’s no reason why’d you have to write such an extension strictly by yourself. You could put it up on google code and invite collaborators. (Or are there wiki code-sharing sites? That might be even more congenial, since it would lower the barrier to entry for collaborators.)

Changes to the Standard Rules on this scale are more likely to happen if they are well tested, and if the alternative implementation gained enough support among users, it would probably have a very good chance of being incorporated into the main library. (Like a fork merging with the main branch in an open source project, I suppose.)

Just some thoughts, since you seem to feel fairly strongly about making areas of the library more accessible to author intervention.

–Erik

I’m flattered by the suggestion!

I’ll consider it, but so far I think my thoughts are only organized far enough to propose a bunch of random ideas on this forum. As Andrew said, this particular case is probably best handled by replacing the existing six lines.

I’ve imagined that most authors will end up developing bits of generalized code when they create a new game, and the more organized ones (like perhaps Emily Short and Aaron Reed) will factor those out into extensions for everyone to share. Right now all this stuff is jumbled up in the rest of my WIP and I don’t know yet how applicable most of it will be, or how it compares to other extensions that do similar things.

If I may offer a more modest suggestion, then:

Create an extension called “My Reusable Code” and drop your replaced 6 lines into it. The next time you do something that you think you might want to use again, do the same. Before too long, you may have a starting place for something more formal!

–Erik

Speaking of which, I hacked up a list of replacement rules for the Rideable Vehicles extension to get it to cooperate with the Custom Library Messages extension. As suggested above I was thinking of offering my adjustments up to the community, but decided to wait since not having experimented yet beyond a single compile with any past tense or pluralised PCs, I can’t be positive it will work in all cases. (I tried to preserve all the flexibility of CLM, but not sure I fully understand that flexibility — it’s a complicated extension. I’ve only really tested rideable vehicles in the third person singular present tense.)

Paul.