I’m new to writing IF and to Inform specifically, but I’m a computer programmer by trade so I expect things to work a certain way. I’m recreating Example 309 “Baritone, Bass” in my own kind of way and I ran into a behavior that I can’t explain.
When I write the code like this: (code example 1)
[code]Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand “male” or “man” or “M” or “boy” as masculine. Understand “female” or “woman” or “F” or “girl” as feminine.
PlayerGender is a gender that varies.
Now PlayerGender is unknown.[/code]
I get the “Thing is a Value” error when setting PlayerGender to unknown.
But when I write it like this: (code example 2)
[code]Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand “male” or “man” or “M” or “boy” as masculine. Understand “female” or “woman” or “F” or “girl” as feminine.
PlayerGender is a gender that varies. It is unknown.[/code]
It compiles and runs fine.
Later I added a line of code like this: (code example 3)
[code]Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand “male” or “man” or “M” or “boy” as masculine. Understand “female” or “woman” or “F” or “girl” as feminine.
Family Relation is a kind of value. The Family Relations are parent, child, sibling, spouse.
PlayerGender is a gender that varies. It is unknown.[/code]
And then it gave me the “General description is something else” error when saying “It is unknown.”
Changing it back to this: (code example 4)
[code]Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand “male” or “man” or “M” or “boy” as masculine. Understand “female” or “woman” or “F” or “girl” as feminine.
Family Relation is a kind of value. The Family Relations are parent, child, sibling, spouse.
PlayerGender is a gender that varies.
Now PlayerGender is unknown.[/code]
Still Throws the “Thing is a value” error when setting PlayerGender to unknown.
But moving the PlayerGender variable to directly after the gender definition like this: (code example 5)
[code]Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand “male” or “man” or “M” or “boy” as masculine. Understand “female” or “woman” or “F” or “girl” as feminine.
PlayerGender is a gender that varies. It is unknown.
Family Relation is a kind of value. The Family Relations are parent, child, sibling, spouse.[/code]
Seems to compile and work as intended.
Why is it behaving like this? I would really expect all of these code examples to work. Is there some nuance that I’m missing? For now it seems that I can get around the issue by being careful about where I declare my variables, but I’d really prefer to declare them all together for readability’s sake.