Trouble with spinning a dial [solved]

Hey All–

I have a dial that can be spun to 4 positions: up, down, left, or right. I don’t understand why my code isn’t working. Can someone show me where I’ve gone wrong?

The dial is here. The description is "A dial that can be spun to four positions: up, down, right, or left.".

Spinning it to is an action applying to one thing and one topic.
Understand "spin [something] to [text]" as spinning it to.
Understand "spin [something] [text]" as spinning it to.

Carry out spinning it to:
	if the noun is the dial:
		if the topic understood is "left":
			now the dial is firsted;
			say "Click[line break]";
		otherwise if the topic understood is "right":
			if the dial is firsted:
				now the dial is seconded;
				say "Click[line break]";
			otherwise if the dial is thirded:
				now the dial is fourthed;
				say "Click[line break]";
			otherwise:
				say "Click[line break]";
		otherwise if the topic understood is "up":
			if the dial is seconded:
				now the dial is thirded;
				say "Click[line break]";
			otherwise:
				say "Click[line break]";
		otherwise if the topic understood is "down":
			if the dial is fourthed:
				now the dial is opened;
				now the north door is enterable;
				say "The door opens.";
			otherwise:
				say "Click[line break]";
		otherwise:
			say "The dial can be spun to up, down, right, or left.";
	otherwise:
		say "That doesn't spin.".

It’s not reading the topics understood. I get this:

spin dial left

The dial can be spun to up, down, right, or left.

What have I done wrong here?

Also, for formatting on this forum, how do I get a > to show up in a post without it blocking off the text after it?

2 Likes

You can precede the > with a \. So to get

>x me

You could type >\>x me.

Sorry I can’t help with Inform code.

A quick note: as a player, I don’t understand how a dial can spin on two axes (both up/down and left/right). Probably I’m just dense and visualizing it wrong but you might want to get another opinion just in case others are like me.

1 Like

Since the topic understood is a snippet and you want to compare it against text, the is operator is not correct. Try exactly matches the text as described in WWI 20.5 Matching and exactly matching.

Carry out spinning it to:
	if the noun is the dial:
		if the topic understood exactly matches the text "left":
			now the dial is firsted;
			say "Click[line break]";
	...

Alternatively, force the topic understood into text form before is comparison using a substitution:

Carry out spinning it to:
	if the noun is the dial:
		if "[topic understood]" is "left":
			now the dial is firsted;
			say "Click[line break]";
	...
3 Likes

@otistdog is correct, but I would add that this is a situation where I would definitely use a new kind of value rather than topics. They are easier to change, make synonyms for, and are in my experience, less fiddly than the whole text/snippit/topic-dance.

1 Like

Hmm. You are right. I envisioned a dial with a pointer on it, and the pointer could point in those directions, but it doesn’t need to be directions. I can change it to colors or something like that, and also tweak the description to describe the pointer better.

3 Likes

Thanks! That did it.

1 Like

@nilsf (and anyone else with an opinion)–

If I change the description to “A dial with a pointer on it. The dial can be spun to point up, down, right, or left.”, does that help with the visualization? Or should I change it to colors?

1 Like

For what it’s worth, the first description made sense to me (it’s got a pointer that points in one of four directions), but I also work at an escape room so I spend a lot of time looking at dials and locks and such.

1 Like

Yes, I can see it now. Just mentioning the pointer makes it work for me.

1 Like

Tangentially, there’s an existing “setting it to” action that you might want to reuse. From the Standard Rules:

Setting it to is an action applying to one thing and one topic.

Check an actor setting something to (this is the block setting it to rule):
    if the actor is the player:
        say "No, [we] [can't set] [regarding the noun][those] to anything." (A);
    stop the action.

Understand "set [something] to [text]" as setting it to.
Understand the command "adjust" as "set".

So you could just add:

Understand "spin [something] to/-- [text]" as setting it to.
The block setting it to rule does nothing when the noun is the dial.
Carry out setting the dial to:
[as your rule above, but you don't need the "That doesn't spin" bit:
the block setting it to rule takes care of it]

You may also want to ensure that the existing commands “turn”, “twist”, and “rotate”, which normally correspond to the turning action (except turn on and turn off which correspond to switching it on and switching it off) work with the dial.

2 Likes

Well, that is handy to know about. But. It is a basic fact of my stubborn and childish nature that if I code something that works, I am loathe to let it go, regardless of whether or not it is the best thing for the project. Two months from now, I will probably discover a painful reason why “setting it to” is the best thing to do and only then will I let my code go.

2 Likes

Pleasure comes only from a fence self-painted … :wink:

2 Likes