I am trying to make an action that applies to a person and reports their name in a sentence after doing it.
The code:
Slapping is an action applying to one visible thing.
Understand “slap [a person]” as Slapping.
After Slapping:
say "You slap [a person] "
Try changing the say token to “You slap [the noun].”
The issue is “a person” is too general for Inform in this context - it indicates any possible person, which is good for the understand statement but isn’t specific enough when it comes to saying something.
As well as @DeusIrae’s correction, stylistically I would make that say part of a Report Slapping: rule, too.
"Untitled"
Laboratory is a room.
Slapping is an action applying to one visible thing.
Understand “slap [a person]” as Slapping.
Report Slapping:
say "You slap [the noun]."
Bill is a person in the Laboratory.
The cat is an animal in the Laboratory.
The statue of a dog is in the Laboratory.
test me with "slap Bill/slap cat/slap dog".
This will give the player “You can’t see any such thing.” messages when the player tries slapping something inanimate:
Laboratory
You can see Bill, a cat and a statue of a dog here.
>slap bill
You slap Bill.
>slap cat
You slap the cat.
>slap dog
You can't see any such thing.
To avoid it, make the grammar more general (and optionally catch inanimate things in a Before rule):
"Untitled"
Laboratory is a room.
Slapping is an action applying to one visible thing.
Understand “slap [something]” as Slapping.
Before Slapping when noun is not a person:
say "There's no point, it's not going to notice." instead.
Report Slapping:
say "You slap [the noun]."
Bill is a person in the Laboratory.
The cat is an animal in the Laboratory.
The statue of a dog is in the Laboratory.
test me with "slap Bill/slap cat/slap dog".