Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

What's the difference between dash and underscore in :match statements

A topic by Garry Francis created Sep 14, 2019 Views: 108 Replies: 5
Viewing posts 1 to 6
Submitted

I want some single-word commands like (say) SLEEP, SMELL or LISTEN. According to the doco, I should be able to use :match "smell -" {}. It says that "The - character can be used to specify nothing." However, I can't see any difference between this and :match "smell _" {}, where the underscore is a wild card.

Is this broken or am I misunderstanding something?

Host

Probably broken. Minus should represent no match. 

Adventuron Cave Sham(bolic).

Host

Documented here, let me know if you think there is a bug:

https://adventuron.io/docs/tut/#QuickStartMatchCommand

Submitted (1 edit)

It works now, but you have to be careful.

An intransitive verb is one that does not require an object, e.g. SLEEP. A transitive verb is one that does require an object, e.g. THROW APPLE. Some verbs may be transitive or intransitive, e.g. JUMP or JUMP CHASM.

Intransitive verbs

If you are using an intransitive verb, use :match "sleep -" {:print "You're not tired."; }

However, if someone enters SLEEP APPLE, the response is "Not right now." That response doesn't really make sense. To do it properly, you really need:

: match "sleep -" {
   : print "You're not tired.";
   : done;
}

: match "sleep _" {
: print "You can't use a noun with that verb.";
}

Or something similar. The order of the two matches is important and the :done; after the first one must be there or it will fall through to the next match and give you a second response.

Transitive verbs

If you are using a transitive verb, use :match "throw *" { :drop; :print "It doesn't go far."; }

However, if someone enters THROW, the response is "Not right now." Once again, that response doesn't really make sense. To do it properly, you really need:

: match "throw -" {
  : print "What do you want to throw?";
  : done;
}

: match "throw *" {
   : drop;
   : print "It doesn't go far.";
}

Either transitive or intransitive

If you are using a verb that may be transitive or intransitive, use :match "throw _" { :print "You jump up and down."; }

However, even here, you really need two matches, as your generic response will vary depending on whether your user has supplied a noun or not. For example:

: match "jump -" {
   : print "You jump up and down.";
   : done;
}

: match "jump *" {
   : print "You can't jump that.";
}

Have I got this right or is there a better (as in more efficient or more elegant) way of doing it?

Wait, what? Presumably SLEEP _ will match against SLEEP on its own as it did in the past? If not then that's messed up a lot of my code, across various games.

Submitted

Your old code will still work. I was lazy and used the underscore for most commands, except a few where it was really silly to do so.