I have an object in a room named 'south;;s'
, which takes an Examine
command.
The idea is if someone tries > LOOK SOUTH
, then this object will get matched, and it will redirect the action to look through a window, which is described as “on the south wall”.
The problem is if the player tries to be silly, and enters > TAKE SOUTH
, the game will say:
The south is fixed in place.
But I don’t want the game to even attempt to handle the action if this redirection object isn’t made for it. In short, I want the parser to say:
You see no south here.
For any action that is not Examine
.
I tried to use the following:
class PeekTarget: Thing {
// The object that will get the LOOK THROUGH action
peekRemapTarget = nil
isFixed = true
// Basic redirections
dobjFor(Search) { remap = peekRemapTarget }
dobjFor(PeekInto) { remap = peekRemapTarget }
dobjFor(PeekThrough) { remap = peekRemapTarget }
dobjFor(LookThrough) { remap = peekRemapTarget }
// For some reason, asDobjFor(LookThrough) did not work here,
// so I had to fill out this command
dobjFor(Examine) {
verify() { }
check() { }
action() {
doInstead(LookThrough, peekRemapTarget);
}
report() { }
}
// This is what is SUPPOSED to drop this object out of scope,
// but it keeps crashing the game instead. I've included the error.
filterResolveList(np, cmd, mode) {
local actionMatches = nil;
if (gActionIs(LookIn)) actionMatches = true;
else if (gActionIs(Search)) actionMatches = true;
else if (gActionIs(PeekInto)) actionMatches = true;
else if (gActionIs(PeekThrough)) actionMatches = true;
else if (gActionIs(LookThrough)) actionMatches = true;
else if (gActionIs(Examine)) actionMatches = true;
if (!actionMatches) {
np.matches = np.matches.subset({m: m.obj != self});
}
}
}
The issue is attempting to do anything with this object now causes the follow error:
Stack trace report
Runtime error: nil object reference
–>/usr/local/share/frobtads/tads3/lib/adv3Lite/action.t, line 876
/usr/local/share/frobtads/tads3/lib/adv3Lite/parser.t, line 2305
/usr/local/share/frobtads/tads3/lib/adv3Lite/command.t, line 812
/usr/local/share/frobtads/tads3/lib/adv3Lite/command.t, line 880
/usr/local/share/frobtads/tads3/lib/adv3Lite/command.t, line 819
/usr/local/share/frobtads/tads3/lib/adv3Lite/parser.t, line 866
/usr/local/share/frobtads/tads3/lib/adv3Lite/parser.t, line 339
/usr/local/share/frobtads/tads3/lib/adv3Lite/main.t, line 180
/usr/local/share/frobtads/tads3/lib/adv3Lite/main.t, line 119
/usr/local/share/frobtads/tads3/lib/adv3Lite/misc.t, line 124
/usr/local/share/frobtads/tads3/lib/adv3Lite/main.t, line 70
/usr/local/share/frobtads/tads3/lib/adv3Lite/main.t, line 24
/usr/local/share/frobtads/tads3/lib/_main.t, line 217
/usr/local/share/frobtads/tads3/lib/_main.t, line 122
/usr/local/share/frobtads/tads3/lib/_main.t, line 31
The online docs don’t include line numbers for source files, so I copy-and-pasted the whole action.t
file into a notepad, and scrolled. apparently line 876 has this:
872 /* apply verb-specific adjustments */
873 foreach (local i in lst)
874 scoreObject(cmd, role, lst, i);
875
876 /* apply object-specific adjustments */
877 foreach (local i in lst)
878 i.obj.scoreObject(cmd, role, lst, i);
Not really sure what to make of this.
I tried defining the Default
action on the redirection object, but it doesn’t seem to do anything.
Defining a Doer
did absolutely nothing. Because “south” wasn’t the name of an object in the room, the Doer
refused to match at all.
Any help would be appreciated, thank you!