Understand conditionally based upon a specific action.

Okay, helpful Inform gurus, I’m back with another question I can’t find an answer to otherwise.

I’m pretty sure I’ve seen this before, so I think it’s possible, but I can’t recall where nor how.

Suppose I have something like…

a wet staircase is a thing.  The description is "The rocks of the staircase are slick with moisture."  Understand "rocks/stairs/stair" as wet staircase.

I would like to be able to use “x moisture” or “touch moisture” to refer to the staircase but disallow “climb moisture” or “go up moisture” as that’s clearly nonsensical. How can I specify that “moisture” only applies as an alias for staircase when describing a staircase and not when utilizing a staircase?

The simplest way to do this is probably to create the moisture as a separate object and redirect the appropriate actions to the staircase:

[code]The moisture is part of the staircase.

Before examining or touching the moisture: now the noun is the staircase.

Before doing something when the noun is the moisture: say “It’s just moisture on the staircase.” instead.[/code]

(The first rule is more specific than the second, so it runs first, and “x moisture” works.)

Very elegant. I like it.

Inform also usually goes with the philosophy that it’s better to understand nonsensical inputs than reject valid ones, which is why the understanding system considers any sequence of matching words valid (rather than restricting it to adjective+noun combinations like the ZIL parser did). So allowing “climb moisture” might not make sense, but most players would have no reason to try it. (Same for e.g. “climb rocks wet stair moisture wet”.)

Not quite how I was thinking it’d work, but beautifully simple.

I guess it’s common in all programming languages, but I’ve found Inform to have a lot of surprising, cute, quirky, or so obvious it’s brilliant kind of tricks. Whenever I read source code from people that really know what they’re doing, I invariably come across something like that, and go “Aaaaaah. So that’s how you can bend Inform to your will!”

Thanks for the input.

And yes, I realize I’m being neurotic by trying to disallow something that 99% of people wouldn’t even try, but for some reason it just offends my sensibilities. Maybe it’s because I remember the language handling of Infocom games (their later years, at least). They really were amazing at handling complex language, especially given the era.

Or even sometimes in my code! I just realized that the code I wrote doesn’t catch stuff like “put rock on moisture” because it only checks the noun, not the second noun. You probably want to change the second rule to:

Before doing something when the current action involves the moisture: say "It's just moisture on the staircase." instead.

If you have a lot of things like that (can’t be interacted with under most conditions) it might be useful to consolidate the rules for them. Scroll Thief uses an “insubstantial” property for that.

One of the things I love about I7 that drives some people crazy - there’s a fair amount of “artistic interpretation” possible in the code. I won’t ever do anything as efficiently as Emily Short or Zarf, but I can still usually make it work.

I only aim for efficiency after the code works. And not always then, either.