Simplifying "if" statements

I’m hoping this is just a simple lack of knowledge about syntax, but it’s such a broad thing I’m struggling to find the right set of keywords to search the documentation.

Is there a basic way to lump a few things together when writing an “if” statement? Let’s use rooms for instance. Is there a way to write this fake code correctly?

say "[if the Library|Parlor|Kitchen is visited]Text[otherwise]Different text."

I’m sure I could lump them together by defining a “kind” but that seems clunky-- in my specific need, it’s just a one-off variation in a NPC dialogue response. Also, I could just write a bunch of [otherwise if…], but same thing, seems like overkill.

Is this what you need?

say "[if the Library is visited or the Parlour is visited or the Kitchen is visited]Yes[otherwise]No".

Ah, yep, simple. Just hadn’t realized I had to write out the “is visited” for each thing. (had tried [if the Library or the Parlour is visited])

Thanks!

Yeah, that’s a common English vs. programming-language thing. In programming languages, OR, AND, etc. only combine full true/false statements like the Library is visited. They’re not smart enough to realize that in some phrases you meant them to combine the values (Library or Parlour or Kitchen) instead.

2 Likes

With the notable and extremely confusing exception of Inform 6 and earlier, which lets you say if(x == 5 or 6 or 7). (It descends from Inform’s original purpose as a glorified assembler with some syntactic sugar—this is how its target architecture’s “branch if equal” opcode works.)

1 Like