Here is some code I’ve written–poorly in all likelihood. I also tried “instead” instead of “carry out” for flushing the toilet. In both cases I receive this message in the game: “I only understand you as far as wanting to flush.”
A toilet is a thing. Toilet is fixed in place. Toilet is in stall #1. The description of toilet is "It's a toilet. As you would expect in a girls' bathroom, the seat is down."
Understand "flush" as flushing. Flushing is an action applying to one thing.
Carry out flushing a toilet:
say "The water swirls away into oblivion."
The way you had it, literally only the command “flush” by itself would do anything, so if you typed “flush toilet”, it was seeing toilet as something extra. Any understand line for an action applying to something needs to have that something as part of the command.
This made the light go off about rules for me…section 17.30’s example is really good. However, this brought up something confusing for me. In the example below, “flush” doesn’t seem to default to the toilet if another item is in the stall. What do I need to add?
[code]“rule-test” by Andrew
stall 1 is a room. a dirty penny is a thing in stall 1.
A toilet is a thing. Toilet is fixed in place. Toilet is in stall 1. The description of toilet is “It’s a toilet. As you would expect in a girls’ bathroom, the seat is down.”
understand the command “flush [something]” as something new.
Understand “flush [something]” as flushing. Flushing is an action applying to one visible thing.
Rule for supplying a missing noun while flushing: now the noun is the toilet.
Carry out flushing a toilet: say “The water swirls away into oblivion.”[/code]
However, the below does.
Does the player mean flushing the toilet: it is very likely.
The “rule for supplying” seems much more flexible, especially if you later might want to flush a DNS cache or a wound, but other than that, is there any big difference between “Rule for” over “Does the player mean”? Or are they equally good for simple cases?
The “supplying a missing noun” activity only applies to cases where the grammar has defined both “verb” and “verb [something]”, and the player uses the first form. Your current code doesn’t do that for “flush”, so the activity never runs – instead, the parser tries to implicitly choose a noun.
Thanks, I think I see. That’s why someone said “you may want to add this.” I assumed it was already taken care of. It’s very good to know these details–they’re impossible (and probably counterproductive) to keep track of when getting introduced to I7, and now I think I have enough knowledge that they mean and reveal something.
Thanks for the clarification. I meant to say that I misunderstood your “add” as “put this in anywhere.” It’s interesting to know why certain things are necessary, and when it doesn’t all make sense at first, explanations help speed up the whole understanding process.
Also, the unlocking example is incredibly useful, so thanks for going the extra mile, again.
Well, I don’t believe it matters whether the rules for supplying a missing noun or second noun go before or after the relevant “understand” lines, so you can pretty much put them anywhere. The most important thing is that they are both there. That said, it is much better to keep them in the same section of code, given that they work together.