Articles of a value?

I’m very new to Inform, and I can’t seem to find anything about this by searching.
My issue is that I can’t seem to attach articles to values that are replacements in text.
Say I have the following:

[code]“A Color Failure” by Erzengel

A color is a kind of value. A color is red, green, blue, coral, or auburn.

A box is a kind of thing. A box has a color. The color of a box is usually auburn. The description of a box is usually “[A color of noun] cube with the text [noun] written on it.”

Test room is a room. The Wizard’s box is a blue box in the test room. The Sorcerer’s box is a box in the test room.

Test me with “x wizard’s box / x sorcerer’s box”.[/code]

This outputs:

Which is missing the “A” or “An” article on the color. Is there a way to get this to work?
I’ve tried manually setting the indefinite article, but Inform 7 says that a value doesn’t have the indefinite article property. After adding some text called the indefinite article, it still doesn’t work.
I can’t just put the “a” in the text because then it would be “A auburn cube” when it should be “An auburn cube”.

Thanks for any help.

You could do it this way:

[code]A box is a kind of thing. A box has a color. The color of a box is usually auburn. The description of a box is usually “[A noun] with the text [printed name of noun] written on it.”

For printing the name of a box when examining: say " cube";[/code]

That does work for a single descriptor, but what about when I’m using the color to describe multiple parts of the object?

A box is a kind of thing. A box has a color. The color of a box is usually auburn. A box has a color called glow. The glow of a box is usually red. The description of a box is usually "[A color of noun] cube with the text [noun] written on it. [The color of noun] panels shimmer slightly. [The glow of noun] glow faintly lights up everything around it."

It should say something like “A blue cube with the text Wizard’s box written on it. The blue panels shimmer slightly. A red glow faintly lights up everything around it.” Granted it’s odd to use blue twice in the description, but the text I’m working with is longer, has more properties and relations that need articles.

The only way I can think to do that with your suggestion is to break it up into part-ofs, in the example “glow is a part of every box”. While possible, I’d really like to avoid that if there’s another option.

As long as you use “The” and not “A,” you should be fine. Unfortunately, the “A/an” magic happens at a pretty low level which isn’t accessible to I7 unless you use indexed text - and it only seems to work for things, not kinds of value.

You can make colors into things (rather than kinds of value) without having to use incorporation. A property can be a thing, no problem.

One pitfall: Things have to be improper-named to get an indefinite article. For some reason, I was unable to declare that “a color is always improper-named,” but I could put “the” in front of the name of every color:

[code]“A Color Failure” by Erzengel

A color is a kind of thing. the red, the green, the blue, the coral, and the auburn are colors.

A box is a kind of thing. A box has a color called hue. The hue of a box is usually auburn. A box has a color called glow. The glow of a box is usually red. The description of a box is usually “[A hue of noun] cube with the text [noun] written on it. [The hue of noun] panels shimmer slightly. [The glow of noun] glow faintly lights up everything around it.”

The verb to be painted implies the hue property.

Test room is a room. The Wizard’s box is a box in the test room. It is painted blue. The Sorcerer’s box is a box in the test room.

Test me with “x wizard’s box / x sorcerer’s box”.[/code]

Simplistic solution:


To say The (C - color):
	say "The [C]";

To say the (C - color):
	say "the [C]";

To say A (C - color):
	if C is auburn:
		say "An [C]";
	else:
		say "A [C]";

To say a (C - color):
	if C is auburn:
		say "an [C]";
	else:
		say "a [C]";

You’d have to add more conditions if you add more colors starting with vowels, but this isn’t a heavy burden, all things considered.

I was thinking the same thing. Here’s an example:

[code]Color is a kind of value. The colors are red, green, blue, coral, or auburn.
A color can be vowel starting or consonant starting. [<-- defaults to consonant]
Auburn is vowel starting.

A box is a kind of thing. A box has a color. The color of a box is usually auburn. A box has a color called glow. The glow of a box is usually red.

The description of a box is usually “[A color of the item described] cube with the text ‘[item described]’ written on it. [The color of the item described] panels shimmer slightly. [The glow of the item described] glow faintly lights up everything around it.”

To say A (C - color):
if C is vowel starting, say “An [c]”;
otherwise say “A [c]”.

To say a (C - color):
if C is vowel starting, say “an [c]”;
otherwise say “a [c]”.

To say The (C - color): say “The [c]”.

To say the (C - color): say “the [c]”.

Test room is a room. The Wizard’s box is a blue box in the test room. The Sorcerer’s box is a box in the test room.

Test me with “x wizard’s box / x sorcerer’s box”.[/code]

All those are awesome ideas. I like the using color as a thing to use the built in magic.
However, based on the fact that you can override “to say a”, here’s what I came up with:

to say the (C - color):
	say "the [C]".
to say The (C - color):
	say "The [C]".
to say a (C - color):
	let first be character number 1 in "[C]" in lower case;
	if first is "a" or first is "e" or first is "i" or first is "o" or first is "u":
		say "an [C]";
	otherwise :
		say "a [C]".
to say A (C - color):
	let first be character number 1 in "[C]" in lower case;
	if first is "a" or first is "e" or first is "i" or first is "o" or first is "u":
		say "An [C]";
	otherwise :
		say "A [C]".

But I wonder if there’s more to it than that. Are there exceptions that would need to be handled in a more generic case? Like “You have a one written on your report.”

[rant]If you have more than one kind of value you want to do this with, you can save yourself some time by using generic phrases as in section 21.6 of the documentation. (This is for Skinny Mike’s version, but obviously you could adapt it to your code.)

[code]Color is a kind of value. The colors are red, green, blue, coral, or auburn.
Material is a kind of value. The materials are wooden, iron, stone, or plastic.

A color can be vowel starting or consonant starting. A material can be vowel starting or consonant starting. [<-- defaults to consonant; you have to declare these separately]
Auburn is vowel starting. Iron is vowel starting.

A box is a kind of thing. A box has a color. The color of a box is usually auburn. A box has a color called glow. The glow of a box is usually red. A box has a material. The material of a box is usually wooden

The description of a box is usually “[A material of the item described] cube with the text ‘[item described]’ written on it. [The color of the item described] panels shimmer slightly. [The glow of the item described] glow faintly lights up everything around it.”

To say A (C - sayable value):
if C is vowel starting, say “An [c]”;
otherwise say “A [c]”.

To say a (C - sayable value):
if C is vowel starting, say “an [c]”;
otherwise say “a [c]”.

To say The (C - sayable value): say “The [c]”.

To say the (C - sayable value): say “the [c]”.

Test room is a room. The Wizard’s box is a blue box in the test room. The Sorcerer’s box is an iron box in the test room.

Test me with “x wizard’s box / x sorcerer’s box”.[/code]

You still have to declare “can be consonant starting etc.” separately for colors and and materials, because Inform won’t let you declare it for sayable values in general, but this saves you writing a bunch of separate phrases.[/rant]

Edit: Wait, that doesn’t work. At first I forgot to change the “The” phrases from color to sayable value, and then when I did it started throwing an extraneous “the” in front of the sentence, even though I didn’t put one in. Can anyone explain this to me?

Huh, that’s odd. When I run your code I get some extra "the"s attached:

You’re too quick for me! I was just editing to hide my faulty code and ask if anyone else knows why that happened. It’s something to do with applying the “sayable value” phrase to “the” as well as to “a”, because when I still had this:

[code]To say The (C - color): say “The [c]”.

To say the (C - color): say “the [c]”.[/code]

it worked fine. But I don’t know what’s going on (and obviously if you take this approach you want to apply those to all sayable values, if possible.)

It only seems to happen on “to say the (c - sayable value)” (lowercase t).

Here’s a quick fix:

To say the (C - sayable value):
	if c is some text:
		say "[c]";
	otherwise:
		say "the [c]";

Obviously this has the limitation that a text property that needs a “the” in front of it won’t work. For example:

A box has some text called the message.
The message of a box is usually "[item described]".

The description of a box is usually "[A material of the item described] cube with the text '[the message of item described]' written on it. [The color of the item described] panels shimmer slightly. [The glow of the item described] glow faintly lights up everything around it."

Will show

which doesn’t have the extra “the” at the beginning of the sentence, but also doesn’t have the desired “the” in the quotes. I think that, for the moment, this is acceptable. But I should probably see if this is in mantis as a bug and report it if not.

–EDIT–
After some more experimenting, I have discovered that it actually happens in examining. The following fully fixes the issue:

carry out examining something:
	instead say "[description of item described]".

It’s obvious that the default rule performs “say “[the description of item described]”.”, which adds a “the” to the text.

–EDIT–
After more experimenting, I have discovered that it is in standard examining rule.

The fixed standard examining rule is listed instead of the standard examining rule in the carry out examining rules.
Carry out examining (this is the fixed standard examining rule):
	if the noun provides the property description and the description of the noun is not "":
		say "[description of the noun][line break]";
	now examine text printed is true.

This fixes an issue with the previous work around that prevented the display of “A box is on the pedestal”.
As you might be able to guess, in the actual standard examining rule, it says “the description of the noun” rather than just “description of the noun”.

The issue would also affect the scene description text rule and possibly things said in other places than the Standard Rules. As far as I can tell the problem will occur whenever a rule tells the game to say “[the text]” or “[The text]”. And presumably a corrsponding problem will occur for rules that tell the game to say “[a text]” or “[A text]”.

I think I’d recommend this alternative fix:

To say a/an/the (T - text): say T.
To say A/An/The (T - text): say T.
To say a/an/the (T - indexed text): say T.
To say A/An/The (T - indexed text): say T.

Felix, if I understand that aright, the idea is that the rules we’ve written for sayable values are already taking care of the articles, so we write rules for text and indexed text that ignore any articles that may be attached to them?

OK, here’s a new issue I’m having:

to say a (C - sayable value):
	if the C provides the property indefinite article and the indefinite article of C is not "":
		say "[indefinite article of C] [C]";
	otherwise:
		let first be character number 1 in "[C]" in lower case;
		if first is "a" or first is "e" or first is "i" or first is "o" or first is "u":
			say "an [C]";
		otherwise :
			say "a [C]".

Such that I could say:

Education is a kind of value. Education is High school, University, Academy, and Community College. Education has some text called indefinite article. The indefinite article of University is "a".

Tim is a person. Tim has an education called Education Level. The education level of Tim is University. The description of Tim is "He went to [a education level of item described]."

This works fine, until I do:

Hair color is a kind of value. Hair color is brown, black, auburn, ginger, red, blond, and chestnut.

Tim has a hair color. The hair color of Tim is auburn. The description of Tim is "He went to [a education level of item described]. [A hair color of item described] strand of hair falls in his eyes."

This fails with an error that “Hair color is not allowed to have an indefinite article”, even though I’m trying to guard against using the indefinite article with the “provides property”. This only happens with values, and would indicate that values are checked for properties at compile time while things check for properties at run time (if I try to use a property in string replacement that doesn’t exist on a thing, it compiles and then fails at run time). So I wonder, is there a compile time way to check for property? I tried “to say a (C - sayable value which provides property indefinite article)”, but that still fails with a compile time error where a C that shouldn’t be going through this particular say apparently is going through this say.

Yes. The Standard Rules have a general phrase to say a sayable value, which I think, delegates that work to specific I6 routines for specific kinds of value, and then a special phrase to say objects with articles.

What “To say the (T - text): say T” does is refer saying the text to the standard printing routine for text. And I guess that routine doesn’t add any articles at all.

[code]There is a room.

To say a (C - sayable value that provides the property indefinite article):
if the indefinite article of C is not “”:
say “[indefinite article of C] [C]”;
otherwise:
let first be character number 1 in “[C]” in lower case;
if first is “a” or first is “e” or first is “i” or first is “o” or first is “u”:
say “an [C]”;
otherwise :
say “a [C]”.

Education is a kind of value. Education is High school, University, Academy, and Community College. Education has some text called indefinite article. The indefinite article of University is “a”.

Tim is a person. Tim is here. Tim has an education called Education Level. The education level of Tim is University.

Hair color is a kind of value. Hair color is brown, black, auburn, ginger, red, blond, and chestnut.

Tim has a hair color. The hair color of Tim is auburn. The description of Tim is “He went to [a education level of item described]. [A hair color of item described] strand of hair falls in his eyes.”[/code]
compiles cleanly for me. Does that match what you’re trying?

(It compiles, but misbehaves. The bug looks similar to—but not the same as—825.)

I’m not sure why it didn’t compile before since I don’t have that particular attempt saved, but that code does compile. However, the function is never run, so it’s hardly a surprise–the compile error I was seeing only occurred if a value without the property was passed into a function that might use that property. Since it never uses that particular function (it will use the default no-articles-for-values or the less specific override if it exists, even if the indefinite article is provided for the value), it never has the opportunity to fail the compile with the given error.
It’s funny how it also breaks other functions beyond itself just by existing, though.