Preventing the player from typing things like go path instead of typing a direcion

I'm creating an adventure that reads like a book and have removed the direction indicator, inventory list information, etc.
To tell the player of possible directions I have put this in the room description text such as "To the north is a forest and you notice a cottage towards the east.
If the player types N or North then the player will go to the forest, but the player may type "GO TO FOREST" or "GO FOREST". I could create commands to cover for this but it would be a lot of work as there are 67 locations. The other way would be to tell the player to type only directions rather than "GO TO..." commands using 'go #object#' as the word pattern with a message, but in the game there are situations when the player must type commands such as "GO CAVE" or "ENTER CAVE" so suggesting that the player only use directions would prevent the player from typing "GO.." commands.
Any suggestions are welcome thanks.

I would suggest that if the description says that a path goes to the forest, then 'forest' should be in the exit's list of alternate names.

If adding these names is too much effort, you could have a script to do it automatically. The first thing that comes to mind would be:

foreach (exit, AllExits()) {
  if (DoesInherit (exit, "compassdirection") and HasObject (exit, "to")) {
    if (HasAttribute (exit, "alt")) {
      // You can't modify a list that's inherited from a type
      //    so we need to create a copy of the list first
      exit.alt = exit.alt
    else {
      exit.alt = NewStringList()
    list add (exit.alt, GetDisplayAlias (

Run in the start script, this would add the name of each exit's destination available as an alias for the exit (effectively making "go forest" equivalent to "go north" as long as the room on the other end has 'forest' in its name.

Hi mrangel.
I was hoping your suggested code would work but I get the following error:

Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.

Sorry, I missed out a line :p Will edit it now

Excellent thanks mrangel.

I'm very pleased with the result.
It will save me a lot of time and work.

Hi mrangel.

It's difficult to understand your code as I'm new to Quest code but one thing I found strange in the code was:
exit.alt = exit.alt
Its like saying A = A but like I said I'm still getting use to the Quest code.

Yeah, I added a comment to that in the hope it would make it clearer.

Basically, if you try to look at an attribute and the object doesn't have it, then Quest will return the same attribute from a type instead.

So if it exists, exit.alt gets the alt attribute of that exit. If the exit doesn't have an attribute by that name, it returns the alt attribute of the type instead. (the types "northdirection", "southdirection", etc all have an lat attribute).

This means that a command like list add (exit.alt, somevalue) will fail - because exit.alt returns northdirection's alt attribute, not the exit's. And the attributes of a type can't be modified in play.

So exit.alt = exit.alt gets the alt attribute which the exit inherits from its type, and copies the list, saving it as an attribute of the actual exit. This means that every exit has its own copy of the alt list, so we can safely add an element to it without modifying the type.

The error message "Cannot modify the contents of this list as it is defined by an inherited type" is one of the most counterintuitive bits of Quest's scripting.

(when you use the = statement to assign a list or dictionary to a variable, the behaviour is a little weird. somevariable = somelist sets somevariable as a pointer to an existing list, so using "list add" or "list remove" on somevariable will modify somelist and vice versa. But someobject.attribute = somelist creates a copy of the list, which is now separate from the original variable)

This topic is now closed. Topics are closed after 60 days of inactivity.