I had a problem I was wrestling with today. I eventually found a solution in the source code for Alabaster. I tweaked it a bit to work with my code, but I thought it would be useful for others who have the same problem, so I am posting it here.
The problem is dealing with actions that act upon touchable things, when your definition of “not touchable” is different than Inform 7’s definition of “not touchable”, which is primarily concerned with local accessibility, such as whether or not a thing is locked in a glass case.
In this case, my definition of an untouchable thing was something that is too far away for the player to touch. For example, the sky or a tree top. This code creates a new “distant” adjective to deal with the problem. Here’s some sample code (tweaked from Alabaster) that presents the solution:
A thing can be distant or nearby. A thing is usually nearby. This is the distant-reach rule: if the action requires a touchable noun and the noun is distant: say "[We] [can't] directly interact with [the noun] because [regarding the noun][they] [are] too far away from [us]." instead; rule fails; if the action requires a touchable second noun and the second noun is distant: say "[We] [can't] directly interact with [the second noun] because [regarding the second noun][they] [are] too far away from [us]." instead; rule fails; The distant-reach rule is listed before the basic accessibility rule in the action-processing rules. Front yard is a room. "You are standing in your front yard with blue sky above you and green grass below." The blue sky is distant scenery in the front yard. "It's the blue sky!". The green grass is scenery in the front yard. "It's green grass!" Test me with "touch grass/touch sky".
This code can also be expanded to include other reasons for “not touchable” things. For example, introducing a “intangible” adjective to deal with things like fog or shadows.