I have three doors—A, B, and C—that all have lockability = lockablewWithKey.
I have one key, with its actualLockList = [doorA].
So far so good. I can unlock door A with the key, and the key does not work on either door B or C.
But I want to customize the failure message when I try to unlock B or C with the key, so I have implemented on both doors B and C a dobjFor(UnlockWith) with a new illogical message when the gIobj is the key to door A…
dobjFor(UnlockWith)
{
verify()
{
if(gIobj == aptKey)
illogical('The key does not fit, the door will not unlock.<.p>');
inherited;
}
}
And it does not work. Instead, when I try to unlock door B with the key by saying unlock door then responding with B when asked which door and then key when asked with what, the game proceeds to unlock Door A with the key…
A breakpoint in the verify() code shows that gIobj is in fact aptKey, and the line of code that sets the illogical message to my custom message is being hit.
Here’s a test bed implementation…
[code]#charset “us-ascii”
#include <tads.h>
#include “advlite.h”
versionInfo: GameID
IFID = ‘445C38A3-AD1B-4729-957A-F584600DE5C1’
name = ‘test’
byline = ‘by Jerry Ford’
htmlByline = ‘by
Jerry Ford’
version = ‘1’
authorEmail = ‘Jerry Ford jerry.o.ford@gmail.com’
desc = ‘Testing unlock.’
htmlDesc = ‘Testing unlock.’
;
gameMain: GameMainDef
initialPlayerChar = me
paraBrksBtwnSubcontents = nil
;
me: Actor ‘me’ @room
“The main man.<.p>”
isHim = true
person = 2
;
-
aptKey: Key ‘key to door a’
“The key to door A. <.p>”actualLockList = [doorA]
;
room: Room ‘room’
“The room.<.p>”
north = doorA
south = doorB
east = doorC
;
-
doorA: Door -> nextRoom ‘() door A’
“Door A. <.p>”lockability = lockableWithKey
isLocked = true
isOpen = nil
; -
doorB: Door -> nextRoom ‘() door B’
“Door B. <.p>”lockability = lockableWithKey
isLocked = true
isOpen = nildobjFor(UnlockWith)
{
verify()
{
if(gIobj == aptKey)
illogical(‘The key does not fit, the door will not unlock.<.p>’);
inherited;
}
}
; -
doorC: Door -> nextRoom ‘() door C’
“Door C. <.p>”lockability = lockableWithKey
isLocked = true
isOpen = nildobjFor(UnlockWith)
{
verify()
{
if(gIobj == aptKey)
illogical(‘The key does not fit, the door will not unlock.<.p>’);
inherited;
}
}
;
nextRoom: Room ‘next room’
“The next room.<.p>”
west = room
;
[/code]
Jerry