Verbs vs Commands

When making an object's verb (let's use "Eat" for an example), you select the verb tab on the object (let's use "Toast" for an example and add the verb "Eat" to the list. Then make sure the verb is displayed in the "Display Verbs" and/ or "Inventory Verbs".

This same verb's script is called if the player types in "eat toast" instead of clicking on the verb in the drop down box or panel tab.

The question I have is:

  1. How do I make a verb that is the go to/default verb for an item that will be called if I only want to add "Eat" to an object's verb list and it will be called without writing in or copy and pasting a script for it each time? I see gray verbs like eat or attack in objects(which are probably inherited in some way). If that's the case, is that an option?

Right now I am calling a different function in each object's verb, which saves a little time, but would rather make my own default verb sort that out just by typing in the verb into the object's verb list.

The game default verb eat doesn't have a script option, just a template. I don't do templates yet.

  1. If a command can/should be used, how can I make the default verb "Eat" point to it?
  2. If a default verb can be made, can I make a (game.attribute) script and have the default verb run that attribute's script.

Something tells me I'm trying to reinvent the wheel, but as I learn more the lines between behaviors tend to blur. If that makes sense.


I'm not quite clear what you're asking for, and also I don't understand Verbs and Commands well enough (Verbs actually are/use Commands "under the hood"), and thus it's probably better to let someone who does, help you with it.


though I'll throw some of this out there for you (as I'm not sure what you're asking for exactly), which might help you:

  1. if you want to use the same Verb (NAME) and SCRIPTING on multiple Objects, an example:
<object name="object_1">
  <inherit name="my_verb_type" />
</object>

<object name="object_2">
  <inherit name="my_verb_type" />
</object>

<type name="my_verb_type">
  <attr name="my_verb" type="script">
    msg (my_verb)
  </attr>
</type>

// by doing this, it does the handling of the 'displayverbs/inventoryverbs' for you (if you need to do whatever / manually handle it, then don't use this '<verb>' method. If you add the verb to the displayverbs and put in the '<verb>', you'll have two identical instances:buttons/hyperlinks of the verb, lol):

<verb>
  <property>my_verb</property>
  <pattern>my_verb</pattern>
  <defaultexpression>You can't do what!</defaultepression>
</verb>
  1. if you want to use a the same Verb (NAME) but use different scriptings, an example:

(I'm just using Functions, but you can also use Object's Script Attribute with Delegates too)

```
  1. if you just want to have multiple command-inputs for a single action:

in the GUI/Editor, for your desired Verb, as a Command or as a Verb, I believe both have a 'pattern' box and/or a 'alt' box, which you can put in multiple command-inputs for it, for examples:

'fight' Command's Pattern box: fight #object_parameter#; attack #object_parameter#; ETC ETC ETC; fight; attack; combat; engage; battle; hit

'fight' Verb's Pattern box: fight; attack; combat; engage; battle; hit
// or:
'fight' Verb's 'alt' (alternative names) box: fight; attack; combat; engage; battle; hit


K.V.

Hello,

I just made a new command with the pattern eat, and I wrote a little script.

Upon entering EAT, the player will eat the toast if the toast is carried, no matter what.

Beyond that, if the player enters EAT while carrying more than one edible item (and none of them are toast), a menu will be displayed to choose what to eat.

Also, if the player is only carrying one edible thing, said thing will automatically be eaten.

NOTE: I added the 'eat' message to each item. Otherwise, it would simply say: "You eat it."


New Command
Command name: eat_alt
Command pattern:
eat

Script:

things_to_eat = NewObjectList()
foreach (o, GetAllChildObjects(player)) {
  if (o.feature_edible) {
    if (HasAttribute(o, "eat")) {
      list add (things_to_eat, o)
    }
  }
}
if ((ListCount(things_to_eat)) = 1) {
  foreach (o, things_to_eat) {
    do (o, "eat")
  }
}
else if ((ListCount(things_to_eat)) > 1) {
  ate = false
  foreach (o, things_to_eat) {
    if (o.name = "piece of toast") {
      do (piece of toast, "eat")
      ate = true
    }
  }
  if (not ate) {
    ShowMenu ("What would you like to eat?", things_to_eat, true) {
      result = GetObject(result)
      do (result, "eat")
    }
  }
}
else {
  msg ("You are carrying nothing edible.")
}

Playable example game:
http://textadventures.co.uk/games/view/68lcojsxqk2dlheb1llyyq/toast


Example game - complete code:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <dynamictemplate name="Eaten">"You eat the " +  object.name  + "."</dynamictemplate>
  <game name="toast">
    <gameid>dcd39f0f-0d08-4b9a-b669-86202ea406a0</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="piece of toast">
      <inherit name="editor_object" />
      <inherit name="edible" />
      <feature_edible />
      <take />
      <eatmsg>You eat the toast.</eatmsg>
    </object>
    <object name="apple">
      <inherit name="editor_object" />
      <inherit name="edible" />
      <feature_edible />
      <take />
      <eatmsg>You eat the apple.</eatmsg>
    </object>
    <object name="orange">
      <inherit name="editor_object" />
      <inherit name="edible" />
      <feature_edible />
      <take />
      <eatmsg>You eat the orange.</eatmsg>
    </object>
    <object name="candy bar">
      <inherit name="editor_object" />
      <inherit name="edible" />
      <feature_edible />
      <take />
      <eatmsg>You eat the candy bar.</eatmsg>
    </object>
  </object>
  <command name="eat_alt">
    <pattern>eat</pattern>
    <script><![CDATA[
      things_to_eat = NewObjectList()
      foreach (o, GetAllChildObjects(player)) {
        if (o.feature_edible) {
          if (HasAttribute(o, "eat")) {
            list add (things_to_eat, o)
          }
        }
      }
      if ((ListCount(things_to_eat)) = 1) {
        foreach (o, things_to_eat) {
          do (o, "eat")
        }
      }
      else if ((ListCount(things_to_eat)) > 1) {
        ate = false
        foreach (o, things_to_eat) {
          if (o.name = "piece of toast") {
            do (piece of toast, "eat")
            ate = true
          }
        }
        if (not ate) {
          ShowMenu ("What would you like to eat?", things_to_eat, true) {
            result = GetObject(result)
            do (result, "eat")
          }
        }
      }
      else {
        msg ("You are carrying nothing edible.")
      }
    ]]></script>
  </command>
</asl>

TRANSCRIPT:

You are in a room.
You can see a piece of toast, an apple, an orange and a candy bar.

> eat
You are carrying nothing edible.

> get all
piece of toast: You pick it up.
apple: You pick it up.
orange: You pick it up.
candy bar: You pick it up.

> eat
You eat the toast.

> eat
What would you like to eat?
1: apple
2: orange
3: candy bar
You eat the candy bar.

> eat
What would you like to eat?
1: apple
2: orange
You eat the apple.

> eat
You eat the orange.


Templates:

These are beyond me, too, but I clicked Filter --> Show Library Elements, and searched for 'eat':

This brought up many choices, but Eaten was the Dynamic Template which held the default eatmsg.

I clicked 'Copy', and changed the line to this: "You eat the " + object.name + ".".

Now, if the command is to eat the orange, even if you didn't enter an 'eat' message, it will print, "You eat the orange."

I switched to Code View for a peek, and it added the Dynamic Template bit I'd altered just before <game name="toast">, and here is that line of code: <dynamictemplate name="Eaten">"You eat the " + object.name + "."</dynamictemplate>


NOTE:

I tried to make an EAT verb first, but I can't figure out how to do anything with a verb that doesn't apply to an object. (Meaning: I tried to just right-click and make a new, stand-alone, one-word verb: EAT but the parser didn't recognize the command, no matter what I tried.)


I really had a day yesterday. I am starting to get so much better at debugging code. Granted my codes are simple but I do copy/paste some serious code from others and have to figure how to tailor them to my game. I got into the CombatTabs files and changed a few things to get a "Look and a Eat" verb to describe an object dead or alive as a script and not a string. The "look verb was over ridden by the lookwhendead string.attribute, so I removed the Look (when dead) text box. Then added my own lookwhendead attribute and had to find the line that called it and changed it to a script call. That was big ta-doings for this old man.

I was successful in getting both verbs to work between the library and Quest and found it really gives you a sense of accomplishment and pride. I usually just beg for scripts online. Ha! Now I find I want to do it myself. And try not to ask for help but as a fellow at work said last night, "Scripting is like take a hard test every time you do it."


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

Support

Forums