How do I write if(condition1 OR condition2 OR ...)

Hello.

Man, am I not reading the manual properly? Why do I not see such simple things? :blush:

I got this after expecting a user input:

If the current answer is "dust":

What I want is this:

If the current answer is "dust" or "Dust" or "dirt" or "Dirt" or ... or ...:

Now this doesn’t work. How can I anticipate more than just one answer from the user?

Ok, I guess this is exceedingly simple, but I can’t see it… thanks in advance, guys. :slight_smile:

BiB

Because of the possibility for syntactic confusion, you can’t use “or” like this in Inform 7. (There’s a feature request for this currently active, that explains some of the difficulties involved.) In the meantime, you need to write out your request in full:

If the current answer is "dust" or current answer is "Dust" or current answer is "dirt" or current answer is "Dirt"...

However, you might want to instead use the tools for matching text strings to do this. (See the chapter “Advanced Text” in the docs.) So, for instance, you could use a regular expression:

if current answer matches the regular expression "(dust|dirt)", case insensitively:

(Also note that in z-code games, the player’s input is going to be all lower-case anyway; you can only preserve the casing of a player’s command in Glulx.)

This is completely off the top of my head as I don’t have Inform 7 in front of me, and I don’t know what extension you’re working with (if any), but I think the correct syntax might be:

if the current answer is "dust" or the current answer is "dirt":

I don’t think you need to worry about capital letters when it comes to user input, either.

Unfortunately, under Glulx I need to worry about that. thanks for that solution (also to aaronius).

I tried it and it works fantastically. Man, I really searched and couldn’t find it in the Docs.

Thank you a lot y’all! :wink:

The “Condition1 or Condition2 or …” Syntax would be helpful. :wink:

BiB

Isn’t there an extension that allows this? I seem to be remember it being written by one of the Erics. “Alternatives” or some such?

…ah yes, Alternatives by Eric Eve

Topics should match case-insensitively even under Glulx. Regexps may be different. I thought the input line was downcased before any processing, but maybe that’s gotten more complicated.