Multiple Command Patterns

GAGE HOLSTON
14 Dec 2017, 22:43

In one of my rooms, you have to get by a bulldog by throwing a steak at him.
I decided to have a command for that room: "THROW STEAK AT BULLDOG"
I was wandering if it was possible to give a command multiple patterns, as the dog has different object names. I'd also like to apply this else where in the game so that the player doesn't have to guess exactly what to type.
And for those who ask: I don't use THROW as a verb for the Steak because it would require the player to type "THROW STEAK WITH DOG" which doesn't make sense.

So in short, is it possible to have more than 1 command pattern for a command. If so, what exactly do I type in the pattern bar?


jmnevil54
14 Dec 2017, 22:56

You can give an object multiple names.

I can't get into imgur at the moment. But in the second or third tab, there's a thing that says "Display names." Simply put the dog's names in there.

Bulldog
Bull
dog
Spike

Capitalization does not matter.

Edit:
You wouldn't type "THROW STEAK WITH DOG" you'd type "throw steak dog." What. And if I'm right, "THROW STEAK AT DOG" should work too!


GAGE HOLSTON
14 Dec 2017, 23:01

I know. That's not what I was asking about.


jmnevil54
14 Dec 2017, 23:05

You don't need multiple patterns. The game already knows.
"Throw steak #object#"

(Plus, see above.)


GAGE HOLSTON
14 Dec 2017, 23:10

Never mind, I figured it out.


K.V.
14 Dec 2017, 23:20

tomayto;tomahto


throw #object1# at #object2#;hit #object2# with #object1#


jmnevil54
14 Dec 2017, 23:23

Well, I'm confused. What happened? Did you just create 2 commands?


Doctor Agon
14 Dec 2017, 23:38

Have a look at the following guide, the Pixie produced
http://docs.textadventures.co.uk/quest/complex_commands.html


jmnevil54
14 Dec 2017, 23:40

+Doctor Agon
I suppose that works.


K.V.
14 Dec 2017, 23:40

In this example, while holding the ball in the room with the target, you can enter:

THROW BALL AT TARGET
THROW THE BALL AT THE TARGET
HIT TARGET WITH BALL
HIT THE TARGET WITH THE BALL
HIT TARGET
HIT THE TARGET
USE BALL
USE THE BALL

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Hit the Target">
    <gameid>8458a1cc-af27-4e62-8cd0-814f4d53ec53</gameid>
    <version>1.1</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <attr name="target hits" type="int">0</attr>
      <statusattributes type="stringdictionary">
        <item>
          <key>target hits</key>
          <value></value>
        </item>
      </statusattributes>
      <attr name="changedtarget hits" type="script"><![CDATA[
        switch (this.target hits) {
          case (5) {
            msg ("<br/><center>YOU HAVE HIT THE TARGET FIVE TIMES AND SAVED THE DAY!<br/><br/><h3>GAME OVER</h3></center>")
            finish
          }
        }
      ]]></attr>
    </object>
    <object name="ball">
      <inherit name="editor_object" />
      <take />
      <usedefaultprefix type="boolean">false</usedefaultprefix>
      <prefix>the</prefix>
      <feature_usegive />
      <use type="script">
        if (target.parent = game.pov.parent) {
          HitTargetFunction (this)
        }
        else {
          msg ("You {random:bounce:juggle:listen to:talk to:pet:use} the ball.")
        }
      </use>
    </object>
    <object name="target">
      <inherit name="editor_object" />
      <usedefaultprefix type="boolean">false</usedefaultprefix>
      <prefix>the</prefix>
      <hit type="script">
        if (not Got(ball)) {
          msg ("You walk over and hit the target with a bare fist.{once:  (I hope you know that doesn't count as a hit.)}")
        }
        else {
          HitTargetFunction (ball)
        }
      </hit>
    </object>
    <command name="hit_target_command">
      <pattern>throw #object1# at #object2#;hit #object2# with #object1#</pattern>
      <script>
        if (not object2 = target) {
          msg ("The point is to hit the target with something.")
        }
        if (Got(object1)) {
          HitTargetFunction (object1)
        }
        else {
          msg ("You're not holding "+GetDisplayName(object1)+".")
        }
      </script>
    </command>
  </object>
  <function name="HitTargetFunction" parameters="object1">
    msg ("The target has been hit.")
    game.pov.target hits = game.pov.target hits + 1
    MoveObjectHere (object1)
  </function>
</asl>

EDIT

Just added an ending when you hit the target five times. (Big whoo-hoo. I know, I know.)


jmnevil54
14 Dec 2017, 23:42

Holy crap, K.V., how to you program games so jelly jaring fast!? Cheese and bologna!


K.V.
14 Dec 2017, 23:45

I use Pixie's guides, just like Dr Agon ordered!


Such LANGUAGE, jmne! (Are you simultaneously angry and hungry?)


Doctor Agon
14 Dec 2017, 23:52

You can also check out these other pages too
http://docs.textadventures.co.uk/quest/using_verbs.html
http://docs.textadventures.co.uk/quest/pattern_matching.html
http://docs.textadventures.co.uk/quest/commands_for_room.html


K.V.
15 Dec 2017, 00:08

Dr. Agon is all like, "take these document links and call me in the morning." (Hehehe.)


SIDENOTE:

That dragon...

It looks like I could be its friend, but it also looks like it could easily eradicate me. (These are two of the things that make dragons cool in my book.)


Doctor Agon
15 Dec 2017, 00:27


Dr. Agon is all like, "take these document links and call me in the morning." (Hehehe.)

Sorry If I gave that impression KV, It's just there's a lot of documentation out there for Quest already, and it's knowing where to look to find the information you need. I know from my experience after reading some of the forum chats or Pixie's tutorials on GitHub, it's given me a new idea, or a different way of tackling a difficult coding problem. I mean, that's what the forum is for, without yours KV, Pixie, HK, DL, and others too numerous to mention, my game wouldn't be half what it is.


K.V.
15 Dec 2017, 00:50

Oh, no!

Don't take me the wrong way!

I was just making a bad doctor pun, not being unpleasant.

I've been meaning to start dropping links to the docs I use each time I post an example.

They're beyond helpful, and I don't think everyone knows they're there. (Especially new users.)

Plus, a lot of work was put into those docs.

It's kind of our responsibility to link to them, right?


K.V.
15 Dec 2017, 00:56

PS

I eagerly await posts from you and everyone else, DrAgon. Whether they include examples, theories, opinions, or whatever.

I love to see all the different ways to accomplish things.

...and sometimes someone even links to a doc I'd missed somehow, just like you just did.

I really wasn't talking smack anyway, though. I promise.