What am I doing wrong???

Here’s the code:

Hinting is an action applying to one visible thing.  Understand "hint [something]" as hinting.

Carry out hinting:
	say "Sorry, I'm afraid there are no clues for this one."

Instead of hinting:
         if the noun is the blanket:
		if the player is not wearing the blanket:
			say "Comfy, wool blankets are best when WORN.";
		else:
			continue the action.	

Here are the results (given that there is a couch and a blanket in the room):

Obviously, I want the desired result to be “Sorry, I’m afraid there are no clues for this one” when hinting the couch. I have tried every combination of rules I can think of that make sense: Check hinting for objects that have clues then carry out hinting for none, Carry out hinting for all with an else line for none at the end of it… this above code is the only thing that even gets me close to the desired result, if not all the way. I’m growing frustrated, and I know I’m going to kick myself as soon as someone can show me what simple thing I must be missing.

Thanks in advance,
Ted

[code]Last carry out hinting: say “Sorry, no hints for this one.”

Carry out hinting about the blanket: say “Here’s a hint about the blanket.”; rule succeeds.[/code]

I like using the “before…instead” formula for this type of thing.

Like, “before doing blah blah blah:
If the noun is the blah blahblah:
Do the special thing instead;”

where you put the Instead at the end of each If section.

Thanks guys, it worked. I ended up going with Draconis’s method. I am a little confused, though. I thought once it’s in the carry out, that the parser has already made the assumption that the rule has succeeded?

FWIW, the problem with your original code was with the indentation:

Instead of hinting: if the noun is the blanket: [all the rest of the code is indented under this, so it's all conditional on "the noun is the blanket"] if the player is not wearing the blanket: say "Comfy, wool blankets are best when WORN."; else: continue the action. [this will get triggered when the noun is the blanket and the player is wearing it] [and then there's nothing when the noun isn't the blanket]

When the noun isn’t the blanket, the Instead rule runs, but never hits a “continue the action.” So it halts processing of the action before the Carry Out, as Instead rules do when there isn’t a “continue the action”… but it never did anything, so you get a blank line.

One way to fix this particular rule would be to change the indentation, and also change the “if” clause so it only applies to the blanket when it is worn:

Instead of hinting: if the noun is the worn blanket: [that is, the noun is the blanket and the blanket is worn] say "Comfy, wool blankets are best when WORN."; else: [note that this is on the same level as the "if"] continue the action.

Another way to do this is to take advantage of the fact that, without “continue the action,” only one Instead rule will run, and it’s the most specific one. So you can do this:

[code}Instead of hinting: say “Sorry, I’m afraid there are no clues for this one.”

Instead of hinting the blanket: say “Comfy, wool blankets are best if you WEAR them.”

Instead of hinting the worn blanket: say “You already seem to be wearing the blanket. That’s all you needed to do with it.”[/code]

If I’ve done this right, Inform will check the third rule first because “worn blanket” is more specific than “blanket”; if that doesn’t apply, it’ll check the second rule because “hinting the blanket” is more specific than “hinting”; and if that doesn’t apply, it checks “hinting.” So we always get the right case. (See §19.16 of the documentation for far more than you need to know about this, though the first paragraph might be helpful.)

Oh, I think the thing here is that when you’re in the carry out, the parser makes the assumption that the action has succeeded. This is different from “rule succeeds,” which basically* says “Stop this rulebook right now! And tell the action-processing machinery that the rulebook was a success, which will usually completely halt processing of the action!” (This is what “After” rules do by default.) In most cases you don’t need to worry about the finer points of the difference between rules succeeding and failing, or actions succeeding and failing–the important thing is that “rule succeeds” (like “rule fails”) stops the processing of the action.

*I think. This is convoluted and I don’t always have a clear grasp on it. It was only fairly recently that I learned that “rule fails” and “… instead” don’t do exactly the same thing.

thanks, matt! that was incredibly helpful, since that’s what my original intention was. i should have seen that indentation error.

An INSTEAD rule always overrides all other rules. You’ll never get to a carry out phase with an instead rule, unless, as Matt said, you continue the action.

There are multiple ways to do this, but here’s what I’d do:

[code]Test Room is a room.

Hinting is an action applying to one visible thing. Understand “hint [something]” as hinting.
A thing has a text called hinttext. The hinttext of a thing is usually “Sorry, I’m afraid there are no clues for [the noun].”

Carry out hinting:
say “[hinttext of the noun][line break]”.

The blanket is a wearable thing in test room. The hinttext is “Comfy, wool blankets are best when WORN.”

The cement block is a thing in Test Room.[/code]

So in that manner, every item has a default hinttext unless you specify a new one.

Interesting. I had no idea that a text property existed, though I suppose it makes complete sense since things can have a value as well. While I’ve already completed my hinting section via Matt’s method, this is definitely some very useful information for future use. Thanks!

One other tweak; if you don’t want hinting (or any action) to cost a turn and skip every-turn rules, you can say:

Hinting is an action out of world applying to one thing.