More multiple conditions trouble

The player has to perform certain tasks to get the below lights to switch on, after which a door get opened. But my code below doesn’t seem to work. Any suggestions?

After the Rectangular Light 7 is switched on and the Rectangular Light 6 is switched on and the Rectangular Light 5 is switched on and the Rectangular Light 4 is switched on and the Rectangular Light 3 is switched on and the Rectangular Light 2 is switched on and the Rectangular Light 1 is switched on:
	say "All the lights begin blinking in unison which is followed by the Passenger Door to swing open";
	now the Passenger Door is unlocked;
	now the Passenger Door is open.

The issue is that after rules are intended to be linked to a particular action. This is made clear in the problem message that you are probably encountering (following is from a test scenario):

Problem. You wrote 'After Switch 1 is switched on and Switch 2 is switched on'  , which seems to introduce a rule taking effect only 'Switch 1 is switched on and Switch 2 is switched on'. But this does not look like an action, since there is no sign of a participle ending '-ing' (as in 'taking the brick', say) - which makes me think I have badly misunderstood what you intended.
See the manual: 7.1 > 7.1. Actions

You can link such a rule to any action by starting it with:

After doing something when...

or, if the logic is not dependent on an action, you can use an every turn rule. (See WWI 9.5 Every turn. Also see WWI 7.5 After rules, WWI 12.2 How actions are processed, and WWI 7.9 All actions and exceptional actions for more details.)

2 Likes

Or if the only way things become switched on is as a specific result of switching on actions (i.e., if it’s never the case that devices can become switched on as a side-effect of something else), it’s straightforward to hang it on an After switching on something rule; the example below adds a property to make it more convenient to discriminate.

A device can be rectangular-lightish. A device is seldom rectangular-lightish.

Rectangular Light 1 is a rectangular-lightish device in the Lab.
Rectangular Light 2 is a rectangular-lightish device in the Lab.

After switching on a rectangular-lightish device:
    if rectangular light 1 is switched on and rectangular light 2 is switched on, say "it worked.";
    else continue the action.

If you know this is the only thing you’ll be using rectangular lights for, that could even be:

After switching on a rectangular-lightish device when every rectangular-lightish device is switched on, say "it worked."

In both cases, the special effect causes the normal “You switch [device name] on…” message to be suppressed because by default the After rule ends action-processing without continuing to Report rules. You could add ‘continue the action’ to those cases if you wanted to reach the Report rules (and also potentially run other After rules).

As your game grows, eventually too many Every turn rules could slow things down, so when there’s a straightforward alternative, you’d might as well take it.

2 Likes