Only Say Statements Missing?

I’ve got quite the bizarre issue on my hands, at least from my perspective.

Consider this code:

[code]“Bug”

A foo is a kind of value.
Bar is a foo.
A foo can be qux or unqux.
A foo is usually unqux.

To activate (active foo - a foo):
say " Waltz";
now active foo is qux.

To say fuz:
say “Tango”;
if bar is unqux:
activate bar.

Weird Space is a room. The cheese is in Weird Space. The description of the cheese is “[fuz]”[/code]

The result:

So what happened to the “Waltz”? Now, if I have a story effect, it still happens, unlike a say phrase.

[code]“Bug”

A foo is a kind of value.
Bar is a foo.
A foo can be qux or unqux.
A foo is usually unqux.

To activate (active foo - a foo):
end the story;
now active foo is qux.

To say fuz:
say “Tango”;
if bar is unqux:
activate bar.

Weird Space is a room. The cheese is in Weird Space. The description of the cheese is “[fuz]”[/code]

The result:

But the end of the story did happen when put in the same place.

To make things even stranger:

[code]“Bug”

A foo is a kind of value.
Bar is a foo.
A foo can be qux or unqux.
A foo is usually unqux.

To activate (active foo - a foo):
say " Waltz";
now active foo is qux.

To say fuz:
say “Tango”;
if bar is unqux:
activate bar.

Weird Space is a room.

Every turn:
say “[fuz]”[/code]

The Waltz is printed normally when in an every turn rule rather than a description.

[code]“Bug”

A foo is a kind of value.
Bar is a foo.
Baz is a foo.
A foo can be qux or unqux.
A foo is usually unqux.

To activate (active foo - a foo):
say " Waltz";
now active foo is qux.

To say fuz:
say “Tango”;
if baz is unqux:
activate bar.

To say dux:
say “Romeo”;
now baz is qux.

Weird Space is a room. The cheese is in Weird Space. The description of the cheese is “[fuz]”.[/code]

This (with baz in the if statement rather than bar) results in a description of the cheese as “Tango Waltz”. However, if the description of the cheese is instead “[fuz] [dux]”, then “Tango Romeo” is printed, with no Waltz in the middle, as if the future appearance of [dux] influences the present [fuz].

What is going on?

What’s going on is that object descriptions are “preflighted” by the library. There’s a line somewhere in there which says (basically)

if the description of O is “”, say “You see nothing special.”
else say the description of O.

When testing equality for a text, the library has to perform all its substitutions (generating output to an internal buffer rather than the screen). That includes your state-setting substitutions.

This doesn’t mean you can’t put state-setting substitutions in text. You can. But if it’s a description property text, you have to be aware that it can be executed more than once, invisibly.

(The [first time]…[only] and [one of]…[or]… constructs are shielded from this effect, in case you’re wondering. You could set up your code in a similar shielded way; this would require some I6 hacking. But it’s better to come up with ways to put important code in action rules rather than text substitutions.)

Hmm, quite the subtle issue. Is this warned about anywhere in the Documentation?

The actual code in my game where this issue turned up involves creating footnotes, which are created the first time a certain word is printed in the game, which could be in different places. Here is some code demonstrating the idea:

[code]“Modestus et Strythio”

[This example is inspired by the Cambridge Latin Course.]

Footnote count is a number that varies. Footnote count is 1.

A latin word is a kind of value.
The latin words are defined by the Table of Latin Words.
A latin word can be done or undone.
A latin word is usually undone.

Table of Latin Words
latin word dictionary entry footnote number
miles-w “Miles, militis, m: soldier” 0
amicus-w “amicus, amici, m: male friend” 0

To activate (active word - a latin word):
if active word is undone:
say " [bracket][footnote count][close bracket]";
choose row with latin word of active word in Table of Latin Words;
now the footnote number entry is footnote count;
increment footnote count;
now active word is done.

Asking for a footnote is an action applying to one number. Understand “footnote [number]” as asking for a footnote.

Carry out asking for a footnote:
if the number understood >= footnote count:
say “You have yet to encounter that footnote.”;
otherwise if the number understood < 1:
say “Footnotes are numbered from 1.”;
otherwise:
choose row with footnote number of number understood in the Table of Latin Words;
say “[italic type][dictionary entry entry][roman type][line break]”

To say miles-s:
say “miles”;
activate miles-w.

To say amicus-s:
say “amicus”;
activate amicus-w.

Prison Outskirts is a room.

Strythio is a person in Prison Outskirts. The description of Strythio is “A Roman [miles-s] and an [amicus-s] of yours.”[/code]

So, with this, when miles and amicus are printed footnotes 1 and 2 activate, but the numbers in brackets hinting that they have been activated aren’t shown due to this issue.

Which fix is ideal for handling this?

It should be possible to use [first time]…[only] for this.

[code]“Modestus et Strythio”

[This example is inspired by the Cambridge Latin Course.]

Footnote count is a number that varies. Footnote count is 1.

A latin word is a kind of value.
The latin words are defined by the Table of Latin Words.
A latin word can be done or undone.
A latin word is usually undone.

Table of Latin Words
latin word dictionary entry footnote number
miles-w “Miles, militis, m: soldier” 0
amicus-w “Amicus, amici, m: male friend” 0

To say (active word - a latin word):
if active word is undone:
say " [bracket][footnote count][close bracket]";
choose row with latin word of active word in Table of Latin Words;
now the footnote number entry is footnote count;
increment footnote count;
now active word is done.

Asking for a footnote is an action applying to one number. Understand “footnote [number]” as asking for a footnote.

Carry out asking for a footnote:
if the number understood >= footnote count:
say “You have yet to encounter that footnote.”;
otherwise if the number understood < 1:
say “Footnotes are numbered from 1.”;
otherwise:
choose row with footnote number of number understood in the Table of Latin Words;
say “[italic type][dictionary entry entry][roman type][line break]”

Prison Outskirts is a room.

Strythio is a person in Prison Outskirts. The description of Strythio is “A Roman miles[first time][miles-w][only] and an amicus[first time][amicus-w][only] of yours.”[/code]

Is that how it should be done? It seems to be working fine.