adv3Lite -- logicalRank issue?

I have two doors in the same room. When the player types “Close Door”, I want to default to a certain door. Likewise, if the player types “Open Door”, I want it to default to the other door. So I use the following statement in the appropriate object: dobjFor(Close) { verify() { logicalRank(120); } } which works, in that the parser will pick that object over the other one.

However, the mechanism to keep track of it being open or closed doesn’t seem to work. I don’t know if I’m missing the mark or if it’s an issue somewhere in the library. For example, take the following code and the resulting script:[code]startroom: Room ‘The Starting Location’
"Add your description here. "
west = westDoor
east = eastDoor
;

  • westDoor : Door ‘small door; red’
    "This is the small red door; it’s currently <<isOpen ? ‘open’ : ‘closed’>>. "
    otherSide = westOtherDoor
    dobjFor(Open) { verify() { logicalRank(120); } }
    dobjFor(Close) { verify() { logicalRank(120); } }
    isListed = true
    ;

  • eastDoor : Door ‘large door; red’
    "This is the large red door; it’s currently <<isOpen ? ‘open’ : ‘closed’>>. "
    otherSide = eastOtherDoor
    isListed = true
    ;
    [/code]The first script is with the logicalRank method commented out (to show the parser confirming), the second script has logicalRank in place.[code]The Starting Location
    Add your description here.

You can see a small door and a large door here.

x doors
large door: This is the large red door; it’s currently closed.
small door: This is the small red door; it’s currently closed.

open door
Which do you mean, the small door or the large door?

small
Opened.

close door
You close the small door.

close door
Which do you mean, the small door or the large door?

small
The small door isn’t open.[/code]Now with the logicalRank method in the door object.[code]The Starting Location
Add your description here.

You can see a small door and a large door here.

x doors
large door: This is the large red door; it’s currently closed.
small door: This is the small red door; it’s currently closed.

open door
You open the small door.

close door
You close the small door.

close door
You close the small door.

close door
You close the small door.

open door
You open the small door.

open door
You open the small door.

open door
You open the small door.[/code]
I can’t use vocabLikelihood because I don’t want to default to the same door object all the time, so is there something I’m missing?

Thanks,
– Mike

If you look at the verify code for dobjFor(Close) – in the Thing class, because that’s what the Door class inherits from – you’ll find that the desired behavior you’re not seeing is caused by the default verify() routine. Which you have gotten rid of. You may need to call inherited() somewhere in there, but I’m not sure of the best way to do that.

Perhaps try this:

verify() { if(!isCloseable) illogical(cannotCloseMsg); if(!isOpen) illogicalNow(alreadyClosedMsg); logicalRank(120); }

Ah, of course. I assumed – for some reason – that logicalRank used some dark magic and kept the inheritance in check for the verify routine. I’ll give it a whirl next chance I get to see if that does the trick.

Thanks, Jim.

– Mike

Thanks, Jim, this now works.

It needs a lot more testing, so if there’s some fallout, I’ll re-post here.