Implementing a dog

I have several questions that are all related to implementing a dog in my game.

First question. This is maybe more general. I have

A canine has a thing called item of interest. 

which is used to keep track of something the dog is interested in interacting with. But there are times when I want to clear it, like:

After a canine (called the dog) taking something:
	now the item of interest of the dog is nothing;
	continue the action.

But I get “*** Run-time problem P60: Attempt to set a variable to the wrong kind of object: you wrote ‘now the item of interest of the dog is nothing’, which sets the value to nothing - but that doesn’t have the kind ‘thing’.”

How do I clear a variable like that?

Second question. Making special persuasion rules. A dog can only carry one item at a time. So I want a command like “Dog, drop it” to work. However Inform makes strange inferences about what it refers to, and I can’t figure out how to change that. For the record, a command like “Dog, drop stick” works fine. Also, is there an

Third question. Again with inferences. If I type something like “Dog, sit” it will sometimes say

>Dog, sit (on the dog) The dog is unable to do that.
A message like there is nothing to sit on or asking what the player wants the dog to sit on would be appropriate. But I don’t understand why it would assume I’m asking the dog to sit on itself. I think it will do this if the dog is the only thing in the room but it’s still strange.

Fourth question. I understand that procedural rules are deprecated. Is there a simple way to do this that doesn’t use procedural rules?

A procedural rule while taking a small canine: ignore the can't take other people rule.
Also, are there things I should take into consideration about carrying a person, or issues that I should be aware of?

Fifth question. What’s the best way to change text like “The small brown dog arrives from the inside.”? I’d like it to say something more like “The small brown dog arrives from inside the shack.” or “The small brown dog comes out of the shack.” But I want different messages depending on the area “arrives from inside the shack”, “arrives from inside the mausoleum”, etc.

Sixth question. Is there a way to set a rule that occurs after a successful persuasion? Basically what I want is for the dog to skip its next action after being persuaded to do something but I need to set a variable after persuasion and the action succeeds. I tried stuff like

After a persuasion with a canine (called the dog) is successful:

but that didn’t work, or I didn’t hit on the right phrasing.

With regard to your third question, I think the problem is that “sit on [something]” invokes the “enter” action (i.e., when you sit on a chair you are entering it). That’s the only action which is triggered by “sit,” so when you don’t specify something to sit on, the machine tries to find a noun and for some reason chooses the dog itself (which it then recognizes as impossible). Have you tried creating a “sit” action which applies to nothing (i.e., which is triggered by the command “sit” without expecting a noun)?

Robert Rothman

The reason you get that run-time error is that the “nothing” pseudo-object is not a thing; it is an object. Arguably, Inform should allow you to assign nothing to a thing, just as it allows you to test whether a thing property/variable contains “nothing”. In other words, it’s arguable that this is a bug. In any case, I generally just use an object in these cases rather than a thing, e.g.: “A canine has an object called the item of interest”.

But you could also assign the thing using a decide phrase that typecasts to I6 when defining the phrase, like so:

To decide which thing is no-thing: (- 0 -)

You would assign the property using “now the item of interest of the dog is no-thing”, and you could test using either nothing or no-thing, e.g. “if the item of interest of the dog is no-thing…”

Another option would be to set the item of interest to the dog itself–or some other neutral object–in lieu of assigning it to nothing, e.g.:

A canine has a thing called the item of interest.

The puppy is a canine. The item of interest of the puppy is the puppy.

After a canine (called the dog) taking something:
	now the item of interest of the dog is the dog;
	continue the action.

–Erik

Dunno about simple, but here’s one way (and it’s a nifty trick in general when you want a standard library rule to apply only some of the time):

[code]
The can’t take other people rule is not listed in any rulebook.

Check taking a person when the noun is not a small canine:
abide by the can’t take other people rule.
[/code]

You can do things like

Persuasion rule for asking a canine to try doing something:
	now stop drooling is true;
	persuasion suceeds.

But of course that only tells you that the persuasion was successful; it doesn’t check that the action the dog tries succeeded.

Something like this might be what you’re after:

After a canine doing something:
	now stop drooling is true.

Not too clever, come to think of it, since it sets the variable whether or not the dog acted because the player told him to or not; also it does not make any distinction between different canine animals.

This may work.

Drooliness is a kind of value. The droolinesses are droolless, droolish and droolful. 
A canine has a drooliness. The drooliness of a canine is droolless.

A persuasion rule for asking a canine (called doggy) to try doing something: 
	now the drooliness of the doggy is droolish;
	rule succeeds.

After someone doing something when the person asked is canine:
	if the drooliness of the person asked is droolish:
		now the drooliness of the person asked is droolful.

[1: stopping droolful dogs from doing things "spontaneously".]
Instead of someone trying doing something when the actor is canine and the drooliness of the actor is droolful:
	now the drooliness of the actor is droolless;
	say "[The actor] prefers to just sit there drooling."

[2: stopping droolful dogs from doing things when ordered.]
Instead of asking someone to try doing something when the person asked is canine and the drooliness of the person asked is droolful:
	now the drooliness of the person asked is droolless;
	say "[The person asked] prefers to just sit there drooling."

Ah yes, this should have been the obvious solution. Thanks.

I went with this route, since I have several conditions of the form “if the dog can see the item of interest of the dog” which I’ve noticed an actor can generally see itself.

Oh yeah that’s nearly perfect.
I went with this approach:

Check taking a person when the noun is not a small canine or the actor is a canine (this is the can't take other people except small canines rule): abide by the can't take other people rule. The can't take other people except small canines rule is listed instead of the can't take other people rule in the check taking rulebook.
because otherwise the can’t take other people except small canines rule would be listed before the can’t take yourself rule which resulted in a weird message if you tried “take self”

Yes this seems to work reasonably well. I think it will take a lot of testing.

Thanks guys!

Does anyone have any thoughts on questions two or five?

You can manually “set pronouns from” an object (or set of objects), so that “it” will refer to that thing if it is neuter (or to the last neuter thing in the list). (See Chapter 16.18)

For example:

A persuasion rule for asking a canine (called doggy) to try dropping something: repeat with item running through things held by doggy: set pronouns from the item.

Or possibly you might prefer:

Before asking someone to try dropping something when the person asked is canine: repeat with item running through things held by the person asked: set pronouns from the item.
That will depend on how such rules interact with other rules you have for canine behaviour.
I’m sure it needs a lot of testing.

That’s a library message for the going action.
Try the extension Default Messages by Ron Newcomb.
(There are lots of library messages for the going action. A look at them in the I6 Templates suggest that the one you quote is number 13 or 19.)