when does "for the first/second/etc time" get checked?

[code]Test Room is a room.

A cube is a kind of thing.

The red cube is a cube in the Test Room.
The green cube is a cube in the Test Room.
The purple cube is a cube in the Test Room.
The yellow cube is a cube in the Test Room.

A person called Bob is here. Before printing the name of Bob while listing nondescript items, say "your long-suffering assistant, ".

A cube can be examined or unexamined. Carry out examining a cube: now the noun is examined.

After examining a cube when exactly two cubes are examined for the first time:
say “‘I mean, the cubes are all basically the same, really,’ says Bob.”

Test 1 with “x red cube / x green cube / x red cube”.
Test 2 with “x red cube / x green cube / x green cube”.
Test 3 with “x red cube / x green cube / x purple cube”.[/code]

The goal here is to get Bob to comment after you have examined two cubes, but only if they are [b]different[b] cubes, and only ever once. So in all three tests, Bob should speak up after the second command. However:

• Test 1 and test 2 result in Bob’s comment after the third command
• Test 3 doesn’t trigger the rule at all.

So, what’s going on here? How to fix it? I have a suspicion that the action is being marked “for the first time” at some point before the noun gets marked as examined, which suggests some possible solutions, but I was hoping someone more familiar with the I6 guts could confirm that for me.

It gets a bit tricky when you have multiple conditions. “when exactly two cubes are examined for the first time”…does that mean the first time any cube is examined, or when we have examined two cubes (x cube. x cube)?

It’s very easy to write a complicated rule that misses the first time. Your first time is very special.

You’d do better possibly to put first/second descriptions in your actual description text. ``` The description of a cube is "[one of]'I mean, the cubes are all basically the same, really,' says Bob. As he says, it's [or]It's [stopping][a noun]." ```

I possibly should not have been reading Oglaf immediately before reading this post.

Yeah, I at first assumed that “for the first/second time” encapsulated all the other conditions of the rule, so that the above rule would read (essentially):

IF (you have successfully examined a cube AND there are currently two examined cubes) for the first time THEN

I can’t use HanonO’s suggested solution, unfortunately. The event really needs to happen after a second cube is flipped from unexamined to examined, and at no other time. I’d like to not have to use an every turn rule, but I guess I will if I have to.

``The description of a cube is "[one of]It's [or]'I mean, the cubes are all basically the same, really,' says Bob.  As he says, it's [or]It's [stopping][a noun]."``

I LOVE OGLAF!!!

[rant]Thanks to a very special IFComp entrant for pointing me to it![/rant]

Hrmm. If you remove the “exactly” clause (i.e., “when two cubes are examined” instead of “when exactly two cubes are examined”), then test 3 will work. That’s a start, I suppose.

Ah, should have been more clear. In the actual WIP (as opposed to this stripped-down test case), the “cubes” do indeed have unique individual descriptions, which need to display before “Bob” “makes his comment”. So this won’t do as a workaround, either.

One more try:

```After examining a cube: if exactly two cubes are examined: say "[one of]Bob says something witty.[or][no line break][stopping]"```

You could also use “Report” if you want this not to override the cube description.

Supposing Bob’s remark is just flavor text, why not have Bob say his line when:

``After examining a cube for the second time, say "Bob says 'I mean, all the cubes are the same, really.'"``

?

Even if you DO examine the same cube twice and Bob makes his comment, is it that important? You’re examining cubes, Bob says not to worry about it. The player should be able to figure out whether he is telling the truth.

It’s important in my actual WIP, in which the specific bits of prose and the order in which they are displayed are pretty significant, yes.

The real problem I am trying to solve is not: how do I make Bob comment on cubes? But rather: how and when does the Inform engine decide that an action is happening ‘for the first time’, and how do additional conditions affect that? My WIP doesn’t have Bob, or cubes. It DOES have a room in which there are several instances of a kind, and a rule that I want to trigger, once, after two of those instances have been examined. The Bob/cubes code above is my attempt to reduce this problem to its simplest generic form as a playable example, so that someone can quickly compile it, test it, and figure out / take a wild guess at / lecture me about why it behaves the way it does.

My apologies if this wasn’t clear.

My apologies for the following example if using Inform’s ‘for the first time’ clause was especially important to you (the issue you have all been wrestling with). But I often do this kind of thing with a variable instead.

Your example used a ‘carry out examining a cube’ rule and an ‘after’ rule as well. I just changed what each does, so I have not added or subtracted rules, nor used an every turn rule, which you wanted to avoid. The following works well:

[code]Test Room is a room.

A cube is a kind of thing.

The red cube is a cube in the Test Room.
The green cube is a cube in the Test Room.
The purple cube is a cube in the Test Room.
The yellow cube is a cube in the Test Room.

A person called Bob is here. Before printing the name of Bob while listing nondescript items, say "your long-suffering assistant, ".

cube-examines is initially 0.

Carry out examining a cube:
increment cube-examines.

After examining a cube:
if cube-examines is 2:
say “‘I mean, the cubes are all basically the same, really,’ says Bob.”

Test 1 with “x red cube / x green cube / x red cube”.
Test 2 with “x red cube / x green cube / x green cube”.
Test 3 with “x red cube / x green cube / x purple cube”.[/code]

So, I tried putting in parentheses:

```After examining a cube when (exactly two cubes are examined for the first time): say "'I mean, the cubes are all basically the same, really,' says Bob."```

and now all three tests deliver the message after turn two. Unfortunately, tests 1 and 2 also deliver the message after turn 3. I’m going to chalk this up to “I don’t understand how ‘for the first time’ works with complex conditions.”

However, this seems to work:

```After examining a cube when exactly two cubes are examined and exactly one cube was examined: say "'I mean, the cubes are all basically the same, really,' says Bob."```

since it checks whether the number of examined cubes changed from one to two that turn (the “was” checks the condition at the beginning of the turn).

ETA: Wade, your solution looks like it’ll fire after the player examines the red cube twice. You could take care of that by incrementing cube-examines only when the player examines an unexamined cube, but then you need to make sure the After rule only fires after examining a cube that was unexamined at the part of the turn… I think you still wind up having to use past tense or to set some kind of flag.

I checked it out when I was wondering what other webcomics I might find amusing, and I checked out Randall Munroe’s recommendations on XKCD.

Oglaf is one of those things - you can’t really believe you’re seeing what you’re seeing, so you just keep on reading. It casts a weird spell.

Much like the spells I cast that cause threads to derail. Ah well - back to the topic!

I really miss the original character, is he dead for good until the writer wants to bring him back?

Sorry for misinterpreting.

What I said before is true - “for the first time” is a thing that only fires once, and if you load it with more conditions that aren’t met you run the risk of that text never being seen. Something simple as

After examining for the first time when the player carries the clay pot…

If the player examines (often done on the first turn) and isn’t holding the clay pot, there’s no other chance to fire it again. Sounds like you want your character to definitely say something, but only at a very specific time, which can be tricky!

Re: Oglaf (which I too discovered through IFComp)

[spoiler]The writer has said "He’s not well, but he definitely isn’t dead

and that there will be a lengthy return arc though apparently they’ve been working on it for three years–sucks to be the one who said “can’t wait!”

Nothing against Ivan but I like the one-shots actually–it’s nice to have a webcomic that isn’t all about huge arcs that take years to resolve.[/spoiler]

Sorry, I misread the original goal.

OK, if we do it using a variable, it is much easier to eliminate the AFTER rule. Some will say that is poor style to be ‘saying’ at the carry out stage, but you can see the benefit of it in an example like this. The following passes all the tests, which I now understand:

[code]Test Room is a room.

A cube is a kind of thing.

The red cube is a cube in the Test Room.
The green cube is a cube in the Test Room.
The purple cube is a cube in the Test Room.
The yellow cube is a cube in the Test Room.

A person called Bob is here. Before printing the name of Bob while listing nondescript items, say "your long-suffering assistant, ".

A cube can be examined or unexamined.

cube-examines is initially 0.

Carry out examining a cube (called the NOWCUBE):
if NOWCUBE is unexamined:
increment cube-examines;
now the NOWCUBE is examined;
if cube-examines is 2:
say “‘I mean, the cubes are all basically the same, really,’ says Bob.”

Test 1 with “x red cube / x green cube / x red cube”.
Test 2 with “x red cube / x green cube / x green cube”.
Test 3 with “x red cube / x green cube / x purple cube”.[/code]