The 'go to' Command (adv3Lite)

I can see that the ‘go to’ command is a nice convenience for the player. But in some circumstances it can get a little weird. This isn’t a library bug, but perhaps a bit of refinement would be practical. Here’s the problem:

I have a large object (a shopping center). It’s visible from various places, as either a Fixture or a Distant, depending on whether you’re close enough to touch it. But once you’re in a location somewhere in the shopping center, the command ‘go to shopping center’ ought to simply reply, “You’re already in the shopping center.” Instead, it asks you to clarify which of the Fixture or Distant objects you’re referring to. Only after you’ve specified one of them does my check() routine run, informing you that that you don’t need to use that command.

Attempting to use a Doer that points to one of the Fixture objects as the desired dobj doesn’t fix this. The parser still asks for clarification before running the Doer, because the scope of ‘go to’ is global.

Is there a convenient way to fix this? I think I’ve worked it out. It requires iterating through the objects that you don’t want to respond to the GoTo command, but this shouldn’t be too tricky:

modify GoTo addExtraScopeItems(whichRole?) { scopeList = scopeList.appendUnique(Q.knownScopeList); // modification: local indx = scopeList.indexOf(nearbyShoppingCenter); if (indx) scopeList = scopeList.removeElementAt(indx); } ;

Well, even though in the past you haven’t seemed too receptive to solutions that require coding around the library :slight_smile:, that is one way to do it.

Create a StringPreParser that intercepts any command line input that begins with Go and contains any one of the destinations within the shopping center (yes, it requires maintaining a list of locations as you add/create/rename them).

Something like…

StringPreParser doParsing(str, which) { if(str.toLower().startsWith('go')) { local locationsList [,,] foreach(local obj in locationsList) { if str.toLower().find(obj.toLower()) { say('You\'re already in the shopping center.<.p>'); str = 'look'; break; } } } return str; } ;

I have not actually tried this code so there may be some syntax issues that need to be resolved, but the gist of it is, if the text entered on the command line starts with go and contains any of the words in the list of shopping center location names, then output the you are there message and proceed as though the look command had been entered (since you must return something in str.

Otherwise, proceed as normal.


An alternative is to make your Distant/Fixture objects return an illogical verify result when the actor is in the shopping center, something like:

+ Distant 'shopping center'
                illogical('Aleady there. '); 

The parser will then choose the shoppingCentre location (which will return an illogicalNow result) rather than any of the Distant/Fixture objects without any disambiguation prompt.