While playing around with the information in DM4 Section 32 “Scope and what you can see”, I ran into some odd behavior that took me a while to track down. The root cause seems to be that the routine ObjectIsUntouchable() doesn’t really function in the way that its name implies. I’m working with Standard Library 6/11 in Inform 6.31, but the code appears to be the same in the current release (6.12.4).
Here’s a scenario to demonstrate:
Constant Story "Hat Trick";
Constant Headline "^(unexpected I6 behavior)^";
Include "Parser";
Include "VerbLib";
Include "Grammar";
Class Room
has light;
Room Start "Starting Point"
with description
"An uninteresting room.",
e_to End;
Room End "Ending Point"
with description
"An uninteresting room.",
w_to Start
has ~light;
Object hat "hat" End
with name 'hat'
has clothing;
Object monitor "monitor" selfobj
with name 'monitor',
curr_obj hat,
description
[;
print "^*****^";
print "<TestScope(", (name) self.curr_obj, ", player) = ", (TorF) TestScope(self.curr_obj, player), ">^";
print "<CommonAncestor(player, ", (name) self.curr_obj, ") = ", (name) CommonAncestor(player, self.curr_obj), ">^";
print "<*ObjectIsTouchable(", (name) self.curr_obj, ") = ", (TorF) ~~ObjectIsUntouchable(self.curr_obj), ">^";
print "<*ObjectIsTouchable(", (name) self.curr_obj, ", true, true) = ",
(TorF) ~~ObjectIsUntouchable(self.curr_obj, true, true), ">";
print "^*****^";
],
react_before
[;
Jump: return self.description(); ! for use in darkness
];
[ TorF p ;
if (p)
print "TRUE";
else
print "FALSE";
];
[ Initialise ;
location = Start;
];
Note that the monitor’s code inverts the result of ObjectIsUntouchable() to get the equivalent of an ObjectIsTouchable() routine.
As can be seen with >X MONITOR at the start, the hat, despite being in a different room, registers as touchable.
This may not seem like a big deal, for two reasons:
1) Trying to interact with the hat fails anyway, because it’s not in scope.
2) The correct result appears if a second flag (which is unmentioned in DM4) is supplied.
However, the counter arguments are that:
A) Nearly every use of ObjectIsUntouchable() in the Standard Library (e.g. ActionSub routines) calls the routine with only the object parameter, and no flags.
B) The routine not doing “what it says on the tin” and in accordance with the provided documentation seems problematic.
C) Changing scope results in an apparently touchable (if not takeable) object at a distance.
To demonstrate C, add:
[ InScope person ;
PlaceInScope(hat);
]; ! place before Include "Grammar"; line
then, from the starting position, try >X HAT (which works as expected) and >TOUCH HAT (which doesn’t).
Is there something I’m missing to explain this behavior? If not, does anyone know if the current version of I6 shows the same behavior? If the behavior is the same, does this count as a bug, or is this known but just accepted that that’s how things are in I6?