Hi! Hello!

Sorry for the n00b question, but how do I parse “hello” AND “hi” in I7?

In I6 that would be -
Answer: switch(noun){
‘hello’, ‘hi’: “The NPC says: ~Hi.~”;
}

In I7 I can parse one word with -
Check answering NPC that “hello”:

But how do I parse “hello”, “hi”, “yo” etc. simultanously?

Thanks!

You can separate the words with a slash, like this:

After answering someone that "hello/hi/yo":
	say "[The noun] [say] 'Hi.'"

If you want to match more complex combinations or greetings with spaces like “Guten Tag” or “Moin moin”, take a look at the Example “Sybil 1” in the Recipe Book, chapter 7.7 Saying Simple Things.

Quoting from there:

If necessary, we can go a step further and define our own token to match a variety of phrases, like this:

Understand "Athenians/Spartans/Greeks" or "hoplite army/forces" as "[Greeks]". Instead of asking the Sybil about "[Greeks]", say "She looks encouraging."

The token “[Greeks]” will match all of “Athenians”, “Spartans”, “Greeks”, “hoplite army”, or “hoplite forces”. It will not match “hoplite” or “forces” alone; it is important to note that the / divides individual words which are understood equivalently, but does not define entire phrases as equivalent. More about how Inform understands specific phrases can be found in the chapter on Understanding.

3 Likes

Works like a charm. Thanks a lot!