Hello! I'm new, just had a quick question.

I don't intend to be long! I've just started poking around with Quest, trying to learn what I can from the tutorial. It's been a little tough so far -- mostly what I've been having a hard time with is understanding the difference between commands and verbs. Beyond that, I can't seem to figure out how to make it so you can throw things at other things... at least, not that I've figured out yet. Anybody have any advice on that? Mostly I want to have it to so you have a baseball or something you can throw at things to have various responses occur.

I've mostly wanted to ask if there are any good examples of Quest coding to look at beyond Cloak in the Darkness I could study from. Thanks!

A verb is basically a special type of command (a command which inherits the type defaultverb, to be more technical).

A command has a pattern, which controls what the player must type in so that they can activate it. This could be something simple like use #object# or open #object#, or more varied like put #object1# in #object2# or turn #object# over. A command also has a script which is run when the command is entered.

With verbs, these two things are predefined; I think you can change them in the desktop version of Quest, but not in the online version. A verb's pattern is verbname #object#, and a verb's script looks to see if the object you're using it on has an attribute with the same name as the verb, and if so it runs that script attribute or displays that message.

Verbs may be more convenient if there's something that's only applicable to one object, or where every object does something different. A command is more appropriate if you've got some action the player character can do, and doing it to different objects will have a similar effect.

For your throwing example you probably want to use a command. Your pattern would probably be throw #object1# at #object2#. But you might also want to make a separate throw #object# command, either for throwing an object in the air, or asking the player what they want to throw it at.

I hope that makes sense?

I hate to admit it, but I'm still stuck. Once you've set the command, where do you go to set the individual responses for each thing you can throw your object at? Would you need to make an if statement for each object in the game you're meant to throw something at, or am I missing something?

Would you need to make an if statement for each object in the game you're meant to throw something at

If throwing something at different objects has different results, yes. It may end up easier to use a switch/case statement instead; which is more efficient if you're comparing one variable to several options.
For example:

switch (object2) {
  case (wall, pillar, table) {
    msg ("The "+GetDiaplayAlias(object1)+" bounces off and rolls back to your feet.")
    MoveObject (object1, game.pov.parent)
  case (vase1, vase2, vase3, crockery, greenhouse) {
    msg ("The "+GetDiaplayAlias(object1)+" shatters with a resounding crash.")
    MoveObject (object1, object2.parent)
    RemoveObject (object2)
  case (hummingbird, cloud) {
    msg ("You try, but you just can't hit it.")

If throwing something at different objects has different results, but the thrown object doesn't make much difference, then you could give objects a script attribute named thrownat or something, which is run when something is thrown at it. Then just have the command run that script attribute if it's found.

If there's a couple of different ways it might behave (like, some objects break when something is thrown at them, sometimes it bounces off, or similar), you could create a couple of flags to indicate what should happen, and have the command check for those rather than listing every possible

There's a few different ways to do it. Which one is best depends on the effects you want throwing an object to have. Does it depend on the thrown object, or the target?

if you still need help with using 'Commands', here's a guide I made/wrote on them:


and if you want, you can take a stab at this other guide of mine (which is what you're stuck at/on with the conditional event/action and subsequent response/re-action you want to do):

http://textadventures.co.uk/forum/quest/topic/civbyvvpc0qviwc0hvoeka/variable-that-impacts-choices-depending-on-its-state#f3d74bc7-c308-49a6-bce2-defa7c0a93e1 (DATA/VARIABLE/Attribute/Variable/VALUE Types)

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk (you might want to try reading the whole post, otherwise skip past the top bit / scroll down a bit, to the bolded 'the two superscript section', and start reading from there on down to the end of my post)

if you want further help and interest in learning quest and its coding:


Option 1: If the object you are throwing the baseball at is limited to one room (easy) --> this applies to a situation like... a refrigerator or a wall or a door or a window... Things that cannot be moved from the room.

A. Right click on the room with the immovable object and add a command.
B. Under command pattern type in something like this:
throw ball at fridge; throw ball toward fridge; throw ball at refrigerator; throw ball toward refrigerator; hit fridge with ball; hit refrigerator with ball
etc... basically, any combination of words that you think someone may type in to throw the ball at the fridge...

The downside here is that any combination of words that you do not think of (or misspellings) will not be recognized. So... if I typed throw ball against fridge or throw bal at fridge the response will cause an error.

C. Then just add your scripts that you want. Example... Add Print message script "The ball bounces of the fridge and the fridge door pops open." Add open object refrigerator script.

Option 2: more complex but deals with TWO movable objects or multiple objects that the ball can be thrown at in the same room (this option is more suitable and realistic)

A. Right click on the room you want the command in and add a command. You can create a command in the game column in the tree of stuff if you want it to be universal.
B. Change the command pattern type to regular expression and type something like this in the empty box beneath:
^(throw|toss|launch|heave) (?<object>.*) (in|into|at|against) (fridge|refrigerator)$

C. Add an If command and switch it to expression. Type object = baseball
D. Add your scripts in the Then box that you want to happen if the "object" object in question is the baseball.
E. If you want... add an else if script if you think the person might reasonable throw any other object against the fridge. Say they have a melon. In the else if box type object = melon and run a print message script like "Why would you want to throw a perfectly good melon against the fridge?"
F. In the else section, add a print message script like "That will not help your cause." and this will handle everything that is not a baseball and not a melon.

Option 3: A lot more complicated (and will make an addition to this soon).

Another option, sorry if someone else said it, I can't read well.

throw command

Pattern: throw #object1# #object2#
The pattern is the stuff you type in the parser, in gameplay, to start the command.

code for command (I'm doing this from memory, please recreate this in the user interface/panel/editing mode.)

if expression (object.throwndart = true) {
  msg ("You already threw the dart!" )
if not has attribute (object1, throwable) {
  msg ("That's not throwable!")
if not has attribute (object2, hittable) {
  msg ("You can't hit that!")
else {
  msg ("You hit the bullseye with the dart!")
  board.throwndart = true

It's something like that.

And then for the objects, you put attributes. It's best to put them in the attributes section if your on the desktop/computer cersion of Quest. If you are using the web version, it's best to use the game -> script -> start script section. On the web version, you can also put attributes on the object -> features, click yes on user interface -> user interface section.

object1, dart

dart.throwable = true

object2, board

board.hittable = true

I hope this helps!

I feel bad for taking your top forum spot/mention.

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