RonG wrote:
If I enter the goto command then press the enter key without including a target of any type, I get an 'Invalid Index' error along with 'cannot be indexed'. I know this is an entry error but it still makes a mess of things.
This happens because of the way you've defined the Goto verb phrase. You wrote this:
Code:
VerbRule(Goto)
'goto' singleDobj
:GotoAction
verbPhrase='go/going to a room'
;
When doing disambiguation, the parser checks the verb phrase for some text in parentheses, which it will parrot back at the player in the event he doesn't supply an object. So you should always have some parenthesized text, ideally written in a way that the parser's prompt makes sense.
Code:
VerbRule(Goto)
'goto' singleDobj
: GotoAction
verbPhrase = 'go/going (where)'
;
Produces this output:
Quote:
> goto
Where do you want to go?
RonG wrote:
If I enable the 'modify thing' section, then I cannot go to any target room. I get a 'not necessary message'. I tried moving that section of code around but it made no difference. Perhaps that section of code is still not sequenced properly?
Room inherits from Thing, so if you don't override the verify method, Room will also block the goto command.
This should fix it - note the empty verify() method has been added to Room.
Code:
modify Room
dobjFor(Goto) {
verify() {}
action() {
me.moveIntoForTravel(self);
me.lookAround(true);
}
}
;
A general note on this command - the way you've implemented it, the player only needs to know the name of the room in order to travel there. You may wish to restrict travel to rooms that the player has visited, which you can do by testing the room's "seen" property.
Code:
modify Room
dobjFor(Goto) {
verify() {}
check() {
if (!seen)
failCheck('You don\'t know where that is. ');
}
action() {
me.moveIntoForTravel(self);
me.lookAround(true);
}
}
;