[I7] Forbidding Actions: Why Doesn't This Work?

Okay, the following tiny example compiles and functions (as far as it goes):

[code]“Apple Example”

The Foyer is a room. “It’s just a foyer. The exit leads east.”

The apple is here.

The Room That Actually Matters is east of the Foyer. “This is the room that actually matters. The exit leads west.”

The small pillar is here. “Here stands a small, faux-Greek pillar, made of plaster[if the pillar encloses the apple][otherwise]. You can’t help but think that what this pillar really needs is an apple on it[end if].” The pillar is a supporter. Check taking the pillar: say “Nah.” instead.

Instead of doing something other than putting [the apple on the pillar] when the pillar is touchable and the apple is enclosed by the player, say “You should really put the apple on the pillar.”[/code]

If the player has the apple and he’s in the room with the pillar, the game won’t let him do anything else except put the apple on the pillar. That’s the intended behavior, so, good.

BUT … un-bracket the bracketed text in the final line of code. NOW, it will compile without complaint … and structurally it resembles some example code in the documentation … but it won’t function. That last line seems, then, to have no effect at all.

Insights and help welcome :frowning:

I don’t know exactly why that doesn’t work, but does this help?

First instead when the pillar is touchable and the apple is enclosed by the player: if the current action is putting the apple on the pillar: continue the action; otherwise: say "You should really put the apple on the pillar."

(You don’t have to say “instead of” any particular action, you see.)

Since “instead” rules run after “before” rules IIRC, you might even want to make that a “before” rule instead, like this:

First before when the pillar is touchable and the apple is enclosed by the player: unless the current action is putting the apple on the pillar, say "You should really put the apple on the pillar." instead.

(The odds are pretty high that someone else will have a better solution.)

It does indeed, thank you! It compiles large, though (46 kilobytes larger than the other way!), so I will have to ponder :frowning:

You can simplify this example down to any of

Instead of doing something other than putting the apple on the pillar:
	...

Instead of doing something other than putting the apple on something:
	...

Instead of doing something other than touching the apple:
	...

You still get the wrong result in each of these cases. In the last one, for example, the compiler seems to parse “instead of doing anything-other-than-touching to the apple”. And similarly the others.

I filed inform7.com/mantis/view.php?id=784 , although I’m surprised nobody’s run into this before.

Thanks for that, and yeah :slight_smile: