For the first time

(An apt topic for my Inform question)

Below is a pared-down torch (I assume there’s no way for it to be both a device and a container right?) The test fails as no score is added. My issues is that “for the first time” appears to be cancelled out by “instead” statement when the check aborts initial attempts.
Can you advise how is this meant to work?

Use scoring.

[a battery-powered torch]

The torch is a container.

The torch can be switched on or switched off. Carry out switching on the torch: now the torch is lit. Carry out switching off the torch: now the torch is unlit. 

Carry out inserting the battery into the torch: now the torch contains the noun.

Check switching on the torch:
	if the torch does not contain the battery:
		say "Nothing happens." instead.

After switching on the torch for the first time: increment score.

Test torch with  "switch on torch /  insert battery into torch / switch on torch"


[rooms]
The atrium is a room. The atrium contains the battery and the torch.

The problem is indeed that “for the first time” tracks the first attempt, not the first success. You’ll need to track it yourself:

The torch can be scored or unscored. The torch is unscored.
After switching on the unscored torch:
    say "The torch switches on! Fantastic!";
    increment the score;
    now the torch is scored.

As a side note, I don’t believe you need any of your carry out rules here; the Standard Rules account for inserting a thing into a container, and switching on/off any object that supports the “switched on” property (whether or not it’s a device).

2 Likes

Ok, that works. Thank you for the quick reply.

I didn’t need that container rule (leftover from when I made torch a device with manual container handling which seemed to be a lot harder than a container with manual switching). The carryout switching rules are what makes this torch lit.

Ah, yes, that makes sense. Carry on then!

Why isn’t there successfully for the first time condition? This feels very clear to the normal reader and, therefore, counter-intuitive to have landed me here :slight_smile:

I imagine anything worth scoring will be linked to numerous dead-ends and checks; Does everything end up needing to be scored?

Unfortunately so. When you attach a “for the Nth time” or “for N turns” condition to a rule, Inform builds a tracker for the other conditions of that rule. But the tracker only counts how often the conditions have been met—and the condition of “switching on the flashlight” is met as soon as the action starts.

Dialog, a separate IF language created after Inform 7, specifically noticed this issue and added special syntax for it. But Inform hasn’t. There are some ways to work around it, at least, though they may need updating for version 10: if you remind me when I’m back at my laptop (or someone else finds it first), I can show you the [@ phrase] substitution, which lets you do this:

say "[one of]Yay! A point![@ increment the score][or]No points any more.[stopping]".