# Rule for deciding whether an actor can touch something?

I want to have a rule in my game for a dog to give it a special rule to determine whether it can touch something or not. For example, in one room I have a piece of beef jerky (edible) on a supporter (the kitchen counter top). The dog should be able to see it but not take it. If the dog is on the same supporter as the food then it can touch it, otherwise it can’t. This way I can have a condition like

``````if the dog can see something edible (called the food) but the dog can't touch the food:
say "The dog looks at [the food] wistfully."``````

But I can’t figure out the right way to write a rule. I already have a rule like

```if the dog carries something edible (called the food): try the dog eating the food; else if the dog can see something edible (called the food): if the dog can touch the food: try the dog taking the food;```

Which works great, except the dog will take any food in the same room as it. So it will take food of a kitchen counter for instance when it shouldn’t. The condition I want is for the dog to only be able to touch something if it is on the same supporter as the dog is on, like if there is food on a bed the dog will first jump onto a bed (supporters can be comfortable in my game, and dogs will only jump onto comfortable supporters. That works fine.)

I’ve tried things like:

``````To decide if (a dog - canine) can reach (a toy - thing):
decide no;
To decide if (a dog - canine) can touch (a toy - thing):
decide no;``````

But neither of these get invoked at all, ever.

Check out section 12.18 of the manual on rules for reaching inside and reaching outside. My guess is you want something like this:

```A rule for reaching inside a supporter: if the person reaching is the dog and the supporter in question does not enclose the dog: deny access.```

Not sure about the exact syntax, though.

There’s also the Far Away extension by Jon Ingold.