I need to detect when a player is trying to go south in a specific situation where I want to redirect the action. (South from the current position is a container, not a room, so I want to change the Travel command to Enter.)
I have implemented a Doer for this purpose…
Doer 'go dir'
if (gCommand.action.direction == southDir)
if(moonRover.position >= 4)
"You're not close enough to the rubble field to enter it. <.p>";
where = [enceladusLandingSite]
Except when I enter s (or south) in the game window with a breakpoint in the if statement, I see in the debugger that gCommand.action.direction is downDir, not southDir as expected.
Since this code is in a somewhat large and complex game that is nearly finished, I tried to isolate it in a test bed environment with just the Doer and a couple of rooms.
And to my surprise, gCommand.action.direction generates a nil object reference error. When I look in the debugger, sure enough, there is no direction reference in gCommand.action. The value of gCommand.action is Travel in both cases, but in one (the game implementation) there is a direction reference and not in the other (the test bed).
Under what circumstances does the direction object get added to the gCommand object? I checked the entire gCommand nest in the debugger and can find no reference to any direction.
And, of more immediate concern (since redirection of the command does work otherwise in my game, just not in the correct direction), why is south being changed to down in the game implementation? I can find nothing in my code that would do this (grep for direction through the entire code base produces no smoking gun).
Here’s the test bed code, where gCommand.action has no direction reference…
IFID = ‘445C38A3-AD1B-4729-957A-F584600DE5C1’
name = ‘test’
byline = ‘by Jerry Ford’
htmlByline = ‘by
version = ‘1’
authorEmail = ‘Jerry Ford firstname.lastname@example.org’
desc = ‘Testing go.’
htmlDesc = ‘Testing go.’
initialPlayerChar = me
paraBrksBtwnSubcontents = nil
me: Actor ‘me’ @room
“The main man.<.p>”
isHim = true
person = 2
room: Room ‘room’
“In the room. <.p>”
up = roof
// south = otherRoom
destination = otherRoom
local ret = nil;
“The door is sealed shut. <.p>”;
otherRoom: Room ‘other room’
“The other room. <.p>”
north = room
roof: Room ‘roof’
down = room
Doer ‘go Dir’
if(gCommand.action.direction == southDir)
“Heading south. <.p>”;