Apply text transformation to `kind of value`?

Is there a low-keystroke way to convert a kind of value to a text so that I can do text transformations on it? It seems like there’s something I’m forgetting to do here but I can’t figure out what it is.

Quality is a kind of value. The qualities are grape, surly, Aquarius, sleepy, rapid, perceptive, and amorous.

A dial is a kind of thing.

The quality dial is a dial. The quality dial has a quality.

Understand "set [something] to [a quality]" as setting the quality of.
Setting the quality of is an action applying to one thing and one quality.

Check setting the quality of something:
	if the noun is not the quality dial, instead say "You can't set that to a quality.".

Carry out setting the quality of the quality dial:
	say "You carefully set the quality dial precisely to [the quality understood in upper case].";
	now the quality of the quality dial is the quality understood.

Control Room is a room. The quality dial is a fixed in place dial in Control Room.

Inform chokes on the quality understood in upper case because a quality is, of course, a kind of value, not text. I’m reluctant to just define a helper function, though, because I’d then have to define a separate helper function for each of several dials in the same room, and this seems pretty redundant:

to decide what text is the capitalized version of (q - a quality):
    decide on "[q]" in upper case.

to decide what text is the capitalized version of (s - a velocity):
    decide on "[s]" in upper case.

to decide what text is the capitalized version of (c - a color):
    decide on "[c]" in upper case.

… etc., where velocity, color, etc. are each also a kind of value.

It seems like there should be an easier way to do this so that I don’t need duplicate boilerplate to decide phrases for every kind of enumerated value, but I can’t figure out what that would be. Is there a way to implicity convert a kind of value to its string, besides putting it in brackets (which doesn’t work inside an existing text substitution), or is there a way to specify in the header of a to decide phrase that the parameter can be any kind of value?

1 Like

You can put it in brackets and enclose the expression in quotation marks and assign this to a temporary variable. This seems to work:

Carry out setting the quality of the quality dial:
	let Q be "[the quality understood]";
	say "You carefully set the quality dial precisely to [Q in upper case].";
	now the quality of the quality dial is the quality understood.
2 Likes

That’ll work! Thanks, StJohn. :slight_smile:

2 Likes

Actually, there is! It’s explained in the chapter “Advanced Phrases” (arguably the most advanced chapter of the documentation), section “Generic Phrases”.

In our case, we’d want sayable value:

To say capitalized version of (val - a sayable value):
	say "[val]" in upper case.

Carry out setting the quality of the quality dial:
    say "You carefully set the quality dial precisely to [capitalized version of the quality understood].";

(I changed the to decide into a to say, which I feel is more appropriate in that case, but I think you can keep the to decide and it’ll work the same.)

3 Likes

Darn it! If I’d taken two minutes to skim the contents of Writing with Inform, I could have skipped the time required to write up a minimal version and a question.

That’s exactly what I was looking for. Thank you so much!

1 Like

Oh, that’s neat! :+1:

I totally need to read the later chapters of the docs more closely. :mag: :smiley:

1 Like

Hats off to Natrium729 for elegance, but some may find a slight tradeoff of elegance (needing to prefix with “text of”) to their liking, because then the code will connect with the upper/lower/title/sentence case phrases already in the Standard Rules.

Less Elegant, More Integrated?
"Dialing In On Quality"

Quality is a kind of value. The qualities are grape, surly, Aquarius, sleepy, rapid, perceptive, laid back, and amorous.

A dial is a kind of thing.

The quality dial is a dial. The quality dial has a quality.

Understand "set [something] to [a quality]" as setting the quality of.
Setting the quality of is an action applying to one thing and one quality.

Check setting the quality of something:
    if the noun is not the quality dial, instead say "You can't set that to a quality.".

To decide which text is text of (item - sayable value):
    decide on "[item]".

Carry out setting the quality of the quality dial:
    say "You carefully set the quality dial precisely to [text of quality understood in upper case].";
    say "You carefully set the quality dial precisely to [text of quality understood in title case].";
    say "You carefully set the quality dial precisely to [text of quality understood in sentence case].";
    now the quality of the quality dial is the quality understood.

Control Room is a room. The quality dial is a fixed in place dial in Control Room.

Test me with "set dial to sleepy / set dial to laid back".
1 Like