Adding a preposition to a verb problems

Sorry for another question... been a while since I've worked with Quest and I should know the answers here but...

I notice that when I try and add a verb like 'bang on', this option auto-pops up:

knock on; knock; rap; knock at; rap at; rap on; bang; bang on; bang at

so, I select it...

However, when I test my game and type 'bang metal' it works just fine.

> bang metal
Hitting the metal or the wall around the metal does nothing to loosen the stone's grip on it's treasure. You'll need something a little more chemical to do the trick.

...and when I type 'bang on hooks' the system things 'on hooks' is the noun and responds with:

> bang on metal
I can't see that. (on metal)

How to fix? Do I need to add a regex command to account for this? Or is it simpler than that?

A command pattern turns into a regular expression using |; which means that it will try the patterns you gave in order until one matches. So the player types "bang on metal". Quest checks the patterns in turn to see if that string matches:

  • knock on #object#; nope.
  • knock #object#, nope
  • rap #object#, nope
  • knock at #object#, nope
  • rap at #object#, nope
  • rap on #object#, nope
  • bang #object#… yes, that matches "bang on metal".
    • So, #object# has captured the string "on metal" and Quest goes looking for an object named "on metal"
    • It doesn't find one, so gives you an error.

If you had "bang" and "bang on" as separate verbs or separate commands, "bang on" would be picked because it has the fewest number of characters inside the #object# match. However, if they're options within the command, the first match wins. So you need to put "bang on" before "bang", ensuring that the bang #object# pattern only matches things that aren't "bang on". Similarly, you need to move "knock at" to before "knock".

In this case, it might be simpler to use a regular expression pattern:
^(knock|rap|bang) ?(on|at|) (?<object>.+)$

Makes sense. Thanks. But how difficult would it be for Quest to put them in that order when it “auto-populates” those verbs? Is there a downside to having those option auto-populate with propositions first? Wouldn’t that solve this problem for all heading forward? Or am I missing something?

Log in to post a reply.