Check rule doesn't work

Check eating cereal: if player does not hold spoon: say "What? You're gonna eat it with your fingers? That's GROSS, man!"; otherwise: if player is not on chair: say "You are not going to eat standing up, fool."; stop the action.

Transcript:

Kitchen
This is the place where you enjoy dining at it’s finest – or you wish you did. There’s a door to the northwest

You can see a refrigerator (closed), a table (on which are a bowl (empty), a box of Wheaties and a spoon) and a chair here.

It’s gettin’ late, so motivate!

ne
You’re not going anywhere without a good breakfast.

One o’clock, two o’clock, three o’clock – Do somethin’, man!

open refrigerator
You open the refrigerator, revealing a bottle.

You really should do something, man.

take bottle
Taken.

Anticipatin’ your next move.

pour milk
Okay, man, you got the milk in the bowl.

Decisions, decisions …

drop all
(the bottle)
Dropped.

Don’t keep me waitin’.

take box
Taken.

On your mark, get set …

pour cereal
Okay, man, you got the Wheaties in the bowl. What a champion you are!

What’s shakin’, bacon?

drop all
(the box of Wheaties)
Dropped.

Make like a cow and moooooove!

eat cereal

Like, what’s next, man?


The player is neither holding the spoon nor sitting in the chair, so one of those “failure messages” should have printed.

Try “if player does not carry spoon” and “if chair does not enclose player”. Might work, might not, I’m too busy to test it right now.

Thanks, Jim. I tried it, and there was no effect.

Okay, here’s the next thing to look at. If you read p. 12.2 of “Writing with Inform,” you’ll note that Instead rules run before Check rules. If you’ve written a Before or Instead rule for eating the cereal (or for eating anything at all) your Check rule won’t be reached.

Again, Jim, thanks, but there are no instead rules that would trump the check rules.

Again, Jim, thanks, but there are no instead rules that would trump the check rules.

Here’s the entire “eating breakfast” sequence:

[code]Chapter - Breakfast

Check eating cereal:
if cereal is not in bowl:
say “The bowl is empty.”;
otherwise:
if milk is not in bowl:
say “Eat dry cereal? Nope.”;
stop the action.

Check eating cereal:
if milk is not in bowl:
say “The bowl is empty.”;
otherwise:
if cereal is not in bowl:
say “Milk’s not very filling by itself.”;
stop the action.

Check eating cereal:
if player does not carry spoon:
say “What? You’re gonna eat it with your fingers? That’s GROSS, man!”;
otherwise:
if chair does not enclose player:
say “You are not going to eat standing up, fool.”;
stop the action.

Check going northeast while player is in Kitchen:
if milk is not in bowl:
say “You’re not going anywhere without a good breakfast.”;
stop the action.
[/code]

What do you get if you type “rules” before trying “eat cereal”?

rules
Rules tracing now switched on. Type “rules off” to switch it off again, or “rules all” to include even rules which do not apply.

eat cereal
[Rule “declare everything initially unmentioned rule” applies.]
[Rule “announce items from multiple object lists rule” applies.]
[Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “investigate player’s awareness before action rule” applies.]
[Rule “player aware of his own actions rule” applies.]
[Rule “check stage rule” applies.]
[Rule “Check eating cereal” applies.]
[Rule “A first turn sequence rule” applies.]
[Rule “every turn stage rule” applies.]
[Rule “Every turn” applies.]
Shake, rattle and move!

[Rule “A last turn sequence rule” applies.]
[Rule “notify score changes rule” applies.]

It’s your first check rule:

Check eating cereal: if cereal is not in bowl: say "The bowl is empty."; otherwise: if milk is not in bowl: say "Eat dry cereal? Nope."; stop the action.

Since the cereal is in the bowl, it’s getting to the “otherwise” code block. Since the milk is in the bowl, it’s skipping that block–but “stop the action” is not in that block (it’d have to be indented a line further). so it’s hitting that line and stopping the action without printing anything.

In general you need to be a bit more careful about where your "stop the action"s are; there should be one in the “if cereal is not in bowl” block, for instance. One good way to do this is to use the word “instead”; if you write:

Check eating cereal: if cereal is not in bowl: say "The bowl is empty." instead;

then when it hits that line it prints the message and stops the action. (When you have “instead” in the middle of a line like this it stops the action.) So whenever you print a failure message you can add “instead” onto it, and then you don’t have to worry about whether you have a “stop the action” in the right place.

matt_w:

I changed the code thusly:

]code]Check eating cereal:
if milk is not in bowl:
say “The bowl is empty.” instead;
otherwise:
if cereal is not in bowl:
say “Milk’s not very filling by itself.”;
stop the action.[/code]

and got this result:

take box
Taken.

Decisions, decisions …

pour cereal
Okay, man, you got the Wheaties in the bowl. What a champion you are!

What’cha gonna do now? Huh? Huh?

drop all
(the box of Wheaties)
Dropped.

What’s Plan B?

eat cereal
What’s up, buttercup?

The message still doesn’t print.

Holmes, since you’re not using the Code tags properly in your posts, it’s impossible for anyone to tell where your indents are. After pasting the code into the message, select all of the code text and use the Code button at the top of the Web page interface. And then use the Preview button to make sure your code is displayed with its indents.

If you don’t do that, nobody can help you.

Check eating cereal: if milk is not in bowl: say "The bowl is empty." instead; otherwise: if cereal is not in bowl: say "Milk's not very filling by itself."; stop the action.

Thought I had. Sorry.

This way of structuring your code might actually work (probably by accident), but I would strongly recommend against doing it this way. You need to write ONE check rule for this situation, not three of them. Something like this (untested):

Check eating cereal: if cereal is not in bowl and milk is not in bowl: say "The bowl is empty." instead; otherwise if milk is not in bowl: say "Eat dry cereal? Nope." instead; otherwise if cereal is not in bowl: say "Milk's not very filling by itself." instead; otherwise if player does not carry spoon: say "What? You're gonna eat it with your fingers? That's GROSS, man!" instead; otherwise if chair does not enclose player: say "You are not going to eat it standing up, fool. Didn't your mother teach you any manners?" instead.
The point of this is to scoop out one possible error after another, all in the proper order.

Thank you, Jim. That did it.
Thanks to all who have helped me with my problems coding the game “Solid Gold.”