Abbreviations

Is there any way in Quest to specify a minimum abbreviation length for an object?

To be more specific: if there will be at some point a match and a matchbox in the same location, saying "get match" will result in a message asking you to specify which you mean. Is there any way to say "the minimum abbreviation for the matchbox is matchb" so as to avoid this message?


Unfortunately not. But "get match" should select the right item, because it only looks for partial matches if there aren't any complete matches.
If you want to make sure that "get mat" and "get matc" won't see the matchbox, you could use the alt attribute (object's alternate aliases) for the match, and add those names for it. That will cause them to be treated as exact matches, so it again doesn't consider partial matches.

This would mean that "get matc" could still get the matchbox, but only if the match isn't visible or the player already has it.


If you want to add this behaviour, you could modify the core function CompareNames or ResolveNameFromList to check for names which are superstrings of existing names.

I'd probably modify the loop at the start of ResolveNameFromList, changing:

    foreach (obj, scope) {
      name = LCase(GetDisplayAlias(obj))
      CompareNames (name, value, obj, fullmatches, partialmatches)
      if (obj.alt <> null) {
        foreach (altname, obj.alt) {
          CompareNames (LCase(altname), value, obj, fullmatches, partialmatches)
        }
      }
    }

to something like:

    matchednames = NewStringList()
    foreach (obj, scope) {
      name = LCase(GetDisplayAlias(obj))
      skip = false
      foreach (found, matchednames) {
        skip = skip or StartsWith (name, found)
      }
      if (not skip) {
        CompareNames (name, value, obj, fullmatches, partialmatches)
        while (ListCount (fullmatches) + ListCount (partialmatches) > ListCount (matchednames)) {
          list add (matchednames, name)
        }
      }
      if (obj.alt <> null) {
        foreach (altname, obj.alt) {
          skip = false
          foreach (found, matchednames) {
            skip = skip or StartsWith (altname, found)
          }
          if (not skip) {
            CompareNames (LCase(altname), value, obj, fullmatches, partialmatches)
            while (ListCount (fullmatches) + ListCount (partialmatches) > ListCount (matchednames)) {
              list add (matchednames, altname)
            }
          }
        }
      }
    }

That's a bit ugly; but causes the parser to skip partial matches whose name starts with the name of an object which has already been found (so you'd have to make sure that the match was higher than the matchbox in the internal object list; but that shouldn't be too difficult)


Thanks - I'll think about that.


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

Support

Forums