first time during scene

I thought it would be possible to do something like:

instead of examining foo for the first time during my scene:

But if you do this, it’s looking for the first time during play, not the first time during my scene. In other words, if you examined foo before the start of my scene, the above code would never fire.

I also tried this:

instead of examining foo during my scene for the first time:

But that won’t even compile.

Is there an elegant way to catch the first time something happens during a scene? At the moment I’m just doing something like this:

my scene has a truth state called foo-examined.

Then I can do this:

instead of examining foo during my scene:
    if the foo-examined of my scene is false:
        say "first time!";
        now the foo-examined of my scene is true;
    otherwise:
        say "whatever.";

But it feels like an ugly hack and becomes a real pain if you need to track several “first times”

So, first, the syntax you want is “Instead of examining the ball when my-scene is happening for the first time”. “Scene is happening” is a condition that can be combined with other conditions in a “when” clause.

More generally:

Don’t think of truth flags as an ugly hack for “first time” clauses. It’s the other way around: “first time” is a handy shortcut for truth flags. It’s nice shortcut to have, but don’t get attached. Never waste more time trying to make a “first time” syntax work than it would have taken you to stick in a flag.

That said, here’s another shortcut, which is sufficiently nifty that I’m surprised it’s not in the standard rules:

To decide whether first occurrence:
	(- {-allocate-storage:first_occurrence}  (I7_ST_first_occurrence --> {-advance-counter:first_occurrence} )++ == 0 -).

With that definition, you can stick in an “if first occurrence” anywhere a condition can go. It’s not attached to any action success or failure; it’s a test-and-set flag specific to that instance of the phrase “first occurrence”.

But wouldn’t that be the first time the my-scene is happening (i.e. if this was a recurring scene it wouldn’t happen the second time the scene runs) rather than the first time examining the ball during my-scene? At least that’s what I would have assumed that line meant (can’t test it right now)?

I’m always hazy on what “for the first time” means - in the case of that condition, it depends on precedence rules.

I’m not a huge fan of truth states either, but I do like binary properties.

[code]foo can be inspected or uninspected.

Instead of examining uninspected foo during my scene:
Now foo is inspected;
…[/code]

Or even:

[code]A thing can be inspected or uninspected.

When a scene begins: Now every thing is uninspected.

Carry out examining something: Now the noun is inspected [be aware this will be skipped by Instead rules][/code]

In this case, no. Test it.

This is why I mentioned the “first occurrence” thing. “Instead of examining the ball when my-scene is happening and first occurrence” is clearer, because you don’t have to figure out what is happening for the first time. It’s whether this condition is being checked for the first time. You just have to remember that “and” conditions are evaluated left to right (so if the scene isn’t happening, the code doesn’t reach the second half of the condition).

I believe you, I just can’t test it until I get home, but that’s some really awkward syntax. It makes me wonder what if I wanted to test if it’s the first time my-scene is happening (I don’t, at the moment, but maybe I might want to at some point in the future) rather than the first time examining something during my-scene?

Ok, now I understand your “first occurrence”. Yes, that does look useful. I’ll have to remember it.