Want a command to check if object has a verb and run object's verb script

I have created a verb called "follow" and assigned it to a character.

The verb (for this character) is set up as a script (so I can do "Do (object, "follow") - it doesn't seem to work unless it is a "Run Script") even though, for this character, all it does is print a message (nothing gets moved anywhere).

In a runthrough my tester used the command "go with" instead of follow. So now I have created a command "go with".

The problem is, I want the "go with" to check if there is a "follow" verb for the object and run that (else generic print message text).

I have worked at this for hours now and NOTHING works. Like, the only thing I have read in the docs is that verbs are treated as an "attribute" therefore hasattribute (object, follow) should work??? Anyway, it doesn't. I can see the verb "follow" appearing as an attribute in the object's "attribute" table so I am tearing my hair out as to why this doesn't work.

Essentially, if I use HasAttribute (object, "follow") it treats literally every object as if it doesn't have the attribute, so clearly Quest is not treating a verb as an attribute.

So what can I do? Just to recap (in brief):

I want to be able to check if an object has a specific verb associated to it, and run the script if so (and then I will add a "else" for a generic response if there is no "follow" verb added to that object).

Please help! Surely this must be something other people want to do???


I can suggest three solutions here.

  1. You could do it the same way the verb itself does (all verbs are just commands with the same built-in script):
if (HasScript (object, "follow")) {
  do (object, "follow")
}
else if (HasString (object, "follow")) {
  msg (object.follow)
}
else {
  msg ("I don't understand your command.")
}
  1. Just run the "follow" verb itself, and let that handle running the script:
do (follow, "script", QuickParams ("object", object))
  1. The most sensible one, I think: change the pattern for the 'follow' command so that it allows itself to be written two different ways. I'm not sure how to do this with the #object# shorthand that Quest uses (perhaps someone more experienced can help with that), but if you make the verb's pattern a regular expression, it would be something like: ^(go with|follow) (?<object>.+)$. Instead of having one command run another, this would just have one verb that can be activated by the player typing two different things (like get/take in the built-in commands)

Log in to post a reply.

Support

Forums