How to use verbs

The Pixie
Verbs are an alternative to commands that can be simplier to use, but do seem to lead to some confusion.

Verbs are always used in conjuction an object, so ROTATE KNOB could be set up as a verb, but STAND UP or JUMP will require commands. You could use a command for ROTATE KNOB, but using a verb is probably simpler.

To create a verb, select the appropriate object, and go to the Verbs tab. Click add, and type in your verb. Your verb will appear in the upper box, and the response can be set in the section below, either "Print a message" or "Run a script". Let us suppose we set this up with a script to make things happen when the dial is turned (how to do scripts is not something I will be dealing with here).

There are actually two parts to a verb. The verb object and the script on our object. The script on our object is just an attribute, which is called "rotate" in this example, but that is really just a name for Quest; the player never sees it.


The Verb Object

The text Quest uses to match against goes into the verb object, and as Quest quietly creates these for you it is easy to miss they even exist. Look for them under the game object. Here is one for our ROTATE verb.

  <verb>
<property>rotate</property>
<pattern>rotate</pattern>
<defaultexpression>"You can't rotate " + object.article + "."</defaultexpression>
</verb>


There are three parts to it. The first is the property element (if you are looking in the GUI, it is called "Attribute", which makes more sense), this is the name of the attribute on the object. The second is the text that Quest will match against. You can change this, to allow for synonyms, with each word separated by semi-colons, like this:

  <verb>
<property>rotate</property>
<pattern>rotate; turn; twist</pattern>
<defaultexpression>"You can't rotate " + object.article + "."</defaultexpression>
</verb>


The third part is what Quest will use if the player tries this verb on something you have not implemented it for (and Quest will even generate this default text for you). You can, of course, change this to your liking. In the GUI you will see more options, but these are the important ones.

Once you have the ROTATE verb set up, Quest will use that for all objects (that have that verb).

Remember that you can also set up synonyms for all your objects on the Object tab, so we could have "dial" and "tuner" for our knob object. The player can TURN DIAL, TWIST TUNER, or any combination. Plus, those synonyms for rotate are there for every object, and those synonyms for the knob are there for every verb. This may not seem a big deal as you start to create your masterpiece, but if you get to beta-testing, and someone wants to use REVOLVE, it is trivial to add that to the ROTATE verb. It could be a real pain to have to update every combination of synonym for every turnable object.

If you start to use types, verbs become even more useful, but that is beyond this discussion...


Verbs are just script

When you create a verb for an object, it is just a script attribute of the object, and scripts can be called whenever you like. Let us suppose you have an object that is a chair, and you create a "sit on" verb, with an appropriate script. That works fine if the player types SIT ON CHAIR, but what if she just types SIT? You need a command to handle that, but you can still use your verb here. Create your command, then, in the script, have it first test that sitting is appropriate (that the chair is in the current room), and if it is, invoke the script on the chair object.

Here is the script for the command:

if (chair.parent = player.parent) {
do (chair, "sit")
}
else {
msg ("Nothing to sit on here!")
}


The second line is where the "sit on" verb is invoked.

By the way, if your verb is multiple words (such as "sit on") Quest will run them together into one long word, "siton". However, some built-in verbs have been set up differently, so in this case the attribute name is just "sit". You can check what name Quest is using by looking on the Attributes tab.

This trick is also useful when you have a verb that can mean different things. You might want your game to handle these:

LIGHT MATCH
STRIKE MATCH
PUNCH MAN
STRIKE MAN

What you can do is set up match with a "light" verb, and man with a "punch" verb. Then add a second verb to each for "strike". All the second verb does is invoke the other verb. So on the match, the "strike" verb does this:

do(this, "light")


On the man, the "strike" verb does this:

do(this, "punch")


In case you are wondering, Quest understands "this" to mean the object to which the script is attached. It is good practice to use "this" rather than the name of the object; for one thing, you may later rename an object, perhaps giving the man a proper name.


Multiple Objects

You can also set up verbs to handle multiple objects, so we could use them for ATTACK GOBLIN WITH KNIFE. Whether this is preferable to using a command is debatable (if there are several things you can attack the goblin with, all doing pretty much the same thing, use a command), but we will look at how it is done.

The first step is to add the verb to the object, in this case the goblin. However, instead of setting "attack" to use a script, set it to "Require another object". this will then put up a list of objects (currently empty) to which you can add the knife by clicking Add. You will then get a new dialogue box, into which you can put your script.

Now go to the verb object. In the lower half of the data, you will see the "Multiple Objects" section. Perhaps the most important is the "Object separator", which defaults to "with; using". This is a list, separated by semi-colons, of words that will go between the two objects, i.e., between GOBLIN and KNIFE. In this case the default is what we want.

If the player just types ATTACK GOBLIN, she will be presented with a menu of appropriate objects, and the "Menu caption" will be the caption for that menu. If there are no such objects around, the "If no objects available..." text is shown.

If there are several monsters that can be attacked with the knife, you would do well to create a new type, say "monster", and have the verb set up on that, and then set your goblin and other foes to be on the "monster" type. For more on types, see here:
http://docs.textadventures.co.uk/quest/ ... types.html


Notes

Some verbs are already implemented, such as "speak to" and "sit on". If you start to type in the Add Verb box, you will see these appear as options. If this is the case, check what the attribute name is. If you add "talk to" as a verb, it will get added as an attribute called "speak", for example.

A few verbs cannot be implements, as they already mean something in Quest. Open and close, and switch/turn on/off are the main examples.

Thanks to those who have commented on this topic. I have updated this post to reflect some of those comments, to keep all the ideas together in one post.

Silver
It's a shame the aliases can't be attached specifically to an object rather than them being universal like commands. Because of English and how one word can mean more than one thing.

I might want to light a match so aliases could be strike; ignite etc.
I may also want to hit a person so aliases might be punch; and strike again.

Pertex
no problem. You can do the following:


<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="test551e">
<gameid>e5eb024a-c76c-4ab7-b74c-858fefdcb825</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<defaultlinkforeground>IndianRed </defaultlinkforeground>
<underlinehyperlinks type="boolean">false</underlinehyperlinks>
</game>
<object name="room">
<inherit name="editor_room" />
<alias>room</alias>
<description type="script">
msg ("You can 'light match', 'strike match' or 'ignite match'")
</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="match">
<inherit name="editor_object" />
<light>match is burning</light>
</object>
</object>
<verb>
<property>light</property>
<pattern>light</pattern>
<defaultexpression>"You can't light " + object.article + "."</defaultexpression>
</verb>
<command name="light">
<unresolved>blabla</unresolved>
<pattern>strike #text#;ignite #text#</pattern>
<script>
HandleSingleCommand ("light "+ text)
</script>
</command>
</asl>

Silver
Cheers!

The Pixie
The way I would do it is to have two verbs for each, and have the strike verb call either the punch script or the light script:

do(this,"punch")


Full demo:

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="verb_test">
<gameid>6bf48f9b-cbc7-42ed-b8e2-eb6e4de9a39b</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="match">
<inherit name="editor_object" />
<light type="script">
msg ("You light the match.")
</light>
<strike type="script">
do (this, "light")
</strike>
</object>
<object name="person">
<inherit name="editor_object" />
<punch type="script">
msg ("You punch the guy.")
</punch>
<strike type="script">
do (this, "punch")
</strike>
</object>
</object>
<verb>
<property>punch</property>
<pattern>punch</pattern>
<defaultexpression>"You can't punch " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>light</property>
<pattern>light</pattern>
<defaultexpression>"You can't light " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>strike</property>
<pattern>strike</pattern>
<defaultexpression>"You can't strike " + object.article + "."</defaultexpression>
</verb>
</asl>

Silver
Yeah, I thought that having a script that could be called upon would be the way around it, but didn't know how. The way I'm doing it now means if I need to edit a script for any reason, I have to remember to edit several.

jaynabonne
You can do "attack goblin with knife" with verbs as well. Here is a sample game that does it:

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="verbytest">
<gameid>c6cd0f76-f213-4c91-b687-1f4c6777e8c3</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<object name="knife">
<inherit name="editor_object" />
</object>
</object>
<object name="goblin">
<inherit name="editor_object" />
<attack type="scriptdictionary">
<item key="knife">
msg ("You stab the goblin with the knife.")
</item>
</attack>
</object>
</object>
<verb>
<pattern>attack #object#</pattern>
<property>attack</property>
<defaulttext>You can't attack.</defaulttext>
<multiobjectdefault>You can't attack with that.</multiobjectdefault>
</verb>
</asl>

The key parts:
- There is an "attack" verb with pattern "attack #object#". The Mulitple Objects section has the default object separator of "with; using".
- The "attack" verb has been added to the goblin. It is set to "require another object".
- There is an entry for the knife, with specific script for the "attack goblin with/using knife".

Clearly, if you use verbs, you have to have a unique separate case for each combination. A command would work better if you wanted to make the handling common to several objects.

The Pixie
Thanks for comments, I have updated the OP to reflect some of your ideas.

Silver
Right, I understand this now I think. So in the object tab under verbs I set up the primary verb as normal, and then instead of copying the entire script to each alias I set up I just enter: do (this, "primary verb") in the aliases script under code view.

The Pixie
Yes.

Silver
Yeah it works great. Cheers. :D

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

Support

Forums