Problem with a horse

I’m using Graham Nelson’s ridable vehicles extension to create a horse. That’s fine but then I created a saddlebag, which I made “part of” the horse’s saddle, which is being worn by the horse.

Then I put objects in the bag, but if I want to take anything from the bag, the parser says “that belongs to your horse” so I have to manually override the objects with “instead of taking” rules.

This is fine for the few objects I put in the bag, but I found if the player starts taking additional objects and putting them in the bag, I’m not handling them. Is there a way to do this more generically, or should I not make the saddlebag part of the horse?

Or, should i make a “instead of taking” for every object?

A highly useful testing command, when you need to find the culprit for a particular behaviour, is RULES. Using it will make Inform display every rule that fires in response to each of your commands. (To show even the rules that are checked but don’t apply, use RULES ALL).

If you turn this on and then try to take something from the saddlebag, you’ll see that the list is pretty short and that there’s an obvious culprit: the ‘can’t take people’s possessions rule’. (In Inform, animals are a kind of person, rather than the other way around.)

Now, if the horse were the only other person in your game, you could just unlist the rule and nobody would be any the wiser. If you have other, non-saddlebagged characters, the thing to do is find that rule in the Standard Rules, copy it into your source, slightly modify it, and get your version to supersede the original:

This is the equestrians sometimes 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 and H is not Mighty Twinklehooves, stop the action with library message taking action number 6 for H;
		let H be the not-counting-parts holder of H;

The equestrians sometimes take people's possessions rule is listed instead of the can't take people's possessions rule in the check taking rules.

[code]This is the equestrians sometimes take people’s possessions rule:
if the noun is not enclosed by Mighty Twinklehooves, abide by the can’t take people’s possessions rule.

The equestrians sometimes take people’s possessions rule is listed instead of the can’t take people’s possessions rule in the check taking rules.[/code]
I could be wrong, but wouldn’t this method be a lot simpler, or am I overlooking something?

Yes, much better. ‘Abide by’ is one of those things that I theoretically know about, but never actually remember to use.

As for enclosure – yeah, that makes more sense. (I’m trying to come up with a situation in which they’d be non-equivalent, but all I’m getting is that if poor Twinklehooves were to be half-absorbed into the body of a horrific composite alien, the enclosure rule would allow you to rifle through his saddlebags but the modified Standard Rules one wouldn’t. This seems, to put it mildly, a circumstance specific enough that it doesn’t need to be addressed by a general rule.)

Also: both versions will, by default, allow the player to walk off with the saddle, the saddlebags and any other tackle the horse is wearing. Easily fixed, if you don’t want to allow it.

Make a game with that premise and I will name my firstborn after you.

If you have many horses, you could generalise it one further like this.

[code]A horse is a kind of rideable animal.

This is the equestrians sometimes take people’s possessions rule:
if the noun is not enclosed by a horse, anonymously abide by the can’t take people’s possessions rule.

The equestrians sometimes take people’s possessions rule is listed instead of the can’t take people’s possessions rule in the check taking rules.[/code]

Hope this helps.

Oh thanks, that saved a lot of work. My wife had suggested making the saddlebag an object that would somehow follow the horse around instead of being worn or part of, and I considered that but it would require an “every turn” rule and that would slow the game down. Plus if I ever decided to move the saddlebag (like if the player removed it from the horse) I’d have to somehow check for that.

No, it wouldn’t; or, rather, the effect would be undetectably tiny. This is in fact how backdrops work; it would be a bit of a hacky solution, I agree, but you wouldn’t get any performance issues from it.

Performance issues in I7 are most likely to be caused by rules that have to check through large arrays repeatedly. Rules that involve repeatedly running through very large tables or lists, or that involve various-to-various relations applying to a common kind (such as things), are the big things to watch out for. But you could throw in a hundred move-the-saddle-to-the-location-of-the-player-type rules and still come up roses.

What maga said. The problem isn’t a single command, or even a load of solitary commands. The problem is when you do stuff that recurses or repeats over itself. Scope can be such a thing – every time you have a condition that asks whether something is visible, you’re searching the model world. In such cases, asking several times in a row is wasteful. You’re better off just asking once and storing the result in a temporary variable.

Just found this thread after I started writing an adventure with a (non-rideable) pack llama with saddlebags that amount to extra inventory space for the player. Knew I had to override the “can’t take people’s possessions” rule somehow, but the parser kept yelling at me for the syntax.
Thank you very much for already having the answer in front of me.