Taking an object from an animal

Hello! I’m trying to let the player remove a key from a cat’s collar. When it test it by typing “take key from cat,” I always get the usual “That seems to belong to the cat” message. I tried to delist the rule about taking things from people with this line:

The can't take people's possessions rule is not listed in any rulebook.

I found it in an article on here - I would love to include the link, but the forum won’t allow it. It’s called “Taking item from animal?” if you want to look it up.

This would be a fine solution since the only other “person” in my story is this cat, but it doesn’t seem to have any effect - I wonder if it’s outdated. Any ideas on how to approach this?

3 Likes

I just made a test game with this rule and it let me take things from the cat. However, you said the key was on the collar, so I wonder if you wrote ‘The key is part of the collar’. That would give the message ‘that seems to be a part of the collar’. If that’s the case, there is a way to fix that. What message do you see when you try to take the key?

Here’s my test game that works for taking the collar (but not the key):

Toyroom is a room.

The cat is in the toyroom.

The collar is worn by the cat.

The key is part of the collar.

The can't take people's possessions rule is not listed in any rulebook.

If you want to be able to take off something that’s part of something, you can do a ‘before’ or ‘instead’ rule, like:

Before taking the key:
	if the key is part of the collar:
		now the key is in the location;

This just ‘disconnects’ the key from the collar and the cat so when you try taking it, it’s free to take.

2 Likes

Here’s what happened when I copied your code into a new project:


Source:

Toyroom is a room.

The cat is in the toyroom.

The collar is worn by the cat.

The key is part of the collar.

The can't take people's possessions rule is not listed in any rulebook.

Before taking the key:
	if the key is part of the collar:
		now the key is in the location;

Test:

>take collar from cat
That seems to belong to the cat.

>take key from cat
That seems to be part of the collar.

Weird, right? So I tried something different in my own project.


Source:

Observatory is a room. 

The cat is an animal in the Observatory.

The collar is a container. The collar is worn by the cat. The collar is transparent.

The collar contains a key.

The can't take people's possessions rule is not listed in any rulebook.

Before taking the key:
	if the key is part of the collar:
		now the key is in the location;

Test:

>take key from cat
But it isn't there now.

>examine collar
In the collar is a key.

>take key from collar
Taken.

But that’s really not what I’m looking for, and the language is unnatural. Any other ideas? Thank you for your help!

I was confused why it was behaving differently between me and you, and wondered if it was because we maybe had different version of Inform.

But I remember now that ‘TAKE FROM’ and “TAKE” are two completely different things in Inform. If you type ACTIONS before ‘take key from cat’ when playing in the IDE you can see that ‘take from’ is technically called ‘removing’ in Inform. You can also see that if you type RULES before ‘take key from cat’ in the IDE with your earlier version of the game that the problem is the ‘can’t remove from people’ rule. You can also see what ‘take from’ does if you go to the Index and click on Actions, then Commands (I didn’t know any of this before this year).

So you just need to modify your code to deal with the removing action:

Toyroom is a room.

The cat is in the toyroom.

The collar is worn by the cat.

The key is part of the collar.

The can't take people's possessions rule is not listed in any rulebook.

Before taking the key:
	if the key is part of the collar:
		now the key is in the location;
		
Before removing the key from the cat:
	if the key is part of the collar:
		now the key is in the location;

If you want to go with the ‘container’ thing, you can use your code with the line:

The examine containers rule does nothing when examining the collar. 

and get rid of the ‘before’ rule.

4 Likes

That seems to do the trick. Thanks!

1 Like

I know you got a satisfactory answer, but just FYI, you can also always fake things like this. You don’t need to work inside Inform’s standard boxes. You can make a key in the location, tag it as undescribed, and then have it be described on taking it. Things do not actually have to be a part of other things; they just need to appear that way in descriptions.

Toyroom is a room.

The cat is here. The description of the cat is "It's wearing a collar.".

The collar is worn by the cat. The description is "A collar[if the key is undescribed] from which dangles a small key[end if].".

The key is here. It is undescribed.  The description is "[if the key is undescribed]A small key dangling from the cat's collar[otherwise]A small key[end if]."

Check taking the key:
	now the key is not undescribed;
	continue the action.
2 Likes

Technically you don’t need this rule, since anything coming into the player’s possession automatically has the ‘undescribed’ flag removed at the end of that turn.

Also, as it’s written here, you theoretically run the risk that the ‘undescribed’ flag is removed but then the taking action is blocked by another check rule so that the key remains untaken. (EDIT this is an illustration of why it’s generally recommended that check rules don’t alter the state of play in any way)

2 Likes

Of course the above code will allow you to take anything from anyone, including people, which might not be the desired behaviour. If you wanted it to work only on animals, try something like the below:

The can't take people's possessions rule does nothing when the holder of the noun is an animal.

Or if it’s just the cat:

The can't take people's possessions rule does nothing when the holder of the noun is the cat.
1 Like