Syntax for a list of actions

Hey-
I have a couple of places where I want the player to perform a list of actions in the correct order to make something happen. So I want something like this:

The CorrectSequence is a list of actions. The CorrectSequence is {push red button, turn blue dial, push green button, turn yellow dial}.

But Inform doesn’t like any of the variations on this I tried. The documentation is filled with examples of how to record and play back stored actions, and how to set correct numerical codes and such, but none of that helps me with this. The closest thing is Leopard Skin, with this code:

When play begins:
add jumping to the maze-sequence;
add clapping to the maze-sequence;
add kweepaing to the maze-sequence.

But Inform won’t let me say anything so specific as

add pushing the red button to the CorrectSequence

What’s the correct way to write a list of specific actions in a specific order?

Then I think I can get the rest of of the programming for the puzzle myself, although if I can’t, you bet I’ll be back.

well, you could accomplish something list-like with a table:

Table of Sequenced Actions
action
pushing red button
turning blue dial
pushing green button
turning yellow dial

But I think this might be a case where a brute force solution would save time and effort over trying to abstract it.

Action-sequence-progress is initially 0.

carry out pushing the red button: now action-sequence-progress is 1.

carry out turning the blue dial when the action-sequence-progress is 1:
   increment the action-sequence-progress.

carry out pushing the green button when the action-sequence-progress is 2:
   increment the action-sequence-progress.

carry out turning the yellow dial when the action-sequence-progress is 3: 
  say "you win.";
  now the action-sequence-progress is 0.
4 Likes

Huh. This seems to work for me (at least it compiles):

CorrectSequence is a list of actions that varies.

When play begins:
	Add pushing the red button to the CorrectSequence;
	add pushing the green button to the CorrectSequence;
	add turning the yellow dial to the CorrectSequence.
3 Likes

Well, there you go. I didn’t have “list of actions that varies”, just “list of actions.” I thought, well, it doesn’t vary. It’s the correct sequence. But adding “that varies” worked.
I wonder why, since it doesn’t vary.

Thanks!

1 Like

I have been pretending like tables don’t exist, because they scare me. So I’m glad to see this may not be the right time to learn them. This solution is interesting. I’m going to play with it.
Thanks again (and again, and again…)

1 Like

Yeah, there doesn’t seem to be a way to define a list that’s constant (not allowed to vary). I’m guessing that it’s probably stored in modifiable memory anyway, so why bother? Dunno. Quirks of the language, I guess. Though maybe someone else knows better: I’m not that great with Inform 7.

But yeah, I just noticed that adding that varies also allows something similar to your original syntax:

The CorrectSequence is a list of actions that varies. The CorrectSequence is {pushing the red button, turning the blue dial, turning the yellow dial}.

(you probably noticed that too, but just in case…)

This is the evilest thing about programming. I never know if I’m really close but just a little off in my wording, or if I’m entirely on the wrong track. In this case, just a little off in wording, so yay me, I guess.

Huh. That still doesn’t work for me. I get this error:

Problem. The constant list ‘pushing the red button, turning the blue dial, turning the yellow dial’ contains an entry ‘pushing the red button’ which isn’t any form of constant I’m able to read.

And the same error for each action. The objects exist and I have spaces after the commas, so I know not whence Inform’s hatred.

1 Like

Could it be that you’re defining the list before defining the objects? Because that’s the exact error you’d be getting if that was the case. Whereas when you define the objects first and then the list, then Josh’s code works (for me at least).

The source code order does not always matter, but sometimes it does. :slight_smile:

About defining a constant list:

When we try to compile this:

The CorrectSequence is a list of actions. 
The CorrectSequence is {pushing the red button, turning the blue dial, pushing the green button, turning the yellow dial}.

… then Inform’s error message includes this hint:

[…]
Or perhaps you wanted to create a name as an alias for a constant value. If so, try something like ‘The lucky number is always 8.’ […]

And that suggested phrasing does indeed seem to work fine; we leave out the “list of actions” declaration, which Inform infers from the list itself, and insert an “always” like this:

The CorrectSequence is always {pushing the red button, turning the blue dial, pushing the green button, turning the yellow dial}.
2 Likes

That surely was it. Gah. I’m trying so hard to organize my code more effectively, and Inform’s pickiness is making that hard!
Thanks!

1 Like