Problem with Switch Statement

Inform 7 6 M 62 (v 9.3)

Hi everyone, I’m back from a whole lot of life and I’m once again trying to do something gameshaped.

Relevant code:

The transporter is a supporter in Core_C.
The transporter is enterable.
The transporter can be inert, receptive, responding, balancing, descending, holding, or ascending (this is its active status property).

Rule for writing a paragraph about the transporter:
	let current status be the active status of the transporter;
	if the player is enclosed by the transporter:
		say "The message you would get standing on the transporter.";
	else:
		say "Curving away before you, a large silvery disk hangs low to the ground. [cont]";
		if the current status is:
			-- inert:
				say "You can make out a fringe of your reflection in its glossy surface.";
			-- otherwise:
				say "The otherwise case, adding the rest later."

Which gets me:

Problem. The case 'inert' is required to be a constant value, rather than something which has different values at different times: specifically, it has to be an active status.

Huh? Specifically, it is an active status, and I’m trying to check if the active status of the platform is it. And what’s all this about inert needing to be a constant value? I’m trying to check the value of current status, not the value of inert, if that’s even a thing that makes sense to do. I’m not sure what I’ve written here, but it’s obviously not what I mean. I’ll do the gigantic if else if I must, but it seems inelegant. And tedious.

Hmm, since there are more than two possible values for this property, I think you might need to explicitly define it as a kind of value – at least, I’ve never tried the syntax you’re using here so not sure if there’s a way to make it work!

Anyway here’s how I’d do it:

Active status is a kind of value.  The active statuses are inert, receptive, responding, balancing, descending, holding, or ascending.
The transporter has an active status called the current status. [these names feel a bit confusing to me, but I just grabbed what you'd been using]
3 Likes

Ah, the value vs. property distinction strikes again. Thanks, Mike.
Yeah, I don’t love the names either, I probably ought to change them for the remains of my sanity before this becomes anything less than a puzzle’s proof of concept :smiley:

1 Like

This looks like a bug. I’ll report it.

1 Like

If the transporter is the only thing with an active status you might find it simpler to write:

Active status is a kind of value.  The active statuses are inert, receptive, responding, balancing, descending, holding, or ascending.
The transporter has an active status.

And then just refer to the active status of the transporter.

1 Like

I7-2587

2 Likes