Changing values using text


I was wondering if there is any way to match the player’s command with values, so that the player can change them.

For example:

Mood is a kind of value. The moods are depressed, manic, steady, anxious and angry.The player has a mood. When play begins: now the player is anxious.

Now, how would I write code so that I can change between the different moods? I’ve already done this:

Mood-switching is an action applying to a value. Understand "change to [mood]" as mood-switching.

However, I had to apply the action to every single mood for it to work. Could I somehow do something along the lines of “if player’s command matches [mood]: now the mood of the player is “[mood]”.”

I tried this, and Inform wouldn’t let me, because text and values are apparently not matchable. Is there any way to do this?

Much luv!

Yes! The player’s chosen value is stored (in this case) to “the mood understood.” You’d then do this:

Carry out mood-switching:
    say "You are now [mood understood].";
    now the mood of the player is the mood understood.

a-haaa…thanks! Makes for much shorter coding…