I know this may have been asked before, but I’m having trouble finding the right solution. I’ve seen similar issues, but not this exact one.
I told the game to ask the player for some input (in this case, a color), which the game will then use to describe some items in the game.
I made this work by implementing an indexed text that varies called “player’s color.”
I then use that to alter the printed name of some items by saying the following:
The printed name of the hat is “[player’s color] hat”;
This works great. If the player inputs “scarlet” as his favorite color, later in the game he sees “a scarlet hat.”
The problem is, if the player says “Take scarlet hat,” the parser doesn’t understand him.
That complaint made sense to me, so I tried the following:
Understand “[player’s color] hat” as the hat.
Inform didn’t like that.
After thinking about this some more, I realized I was basically trying to do what happens in Spellbreaker where the player can rename the cubes to whatever he wants and then use those names when interacting with them. I’ve been able to achieve the first part (renaming an object to whatever he wants) but not the second (using that name to interact with the object).
When I’ve looked for answers this question, they’ve all dealt with referring to objects by variable conditions (say, broken and fixed) or to some other new name that has been chosen by the author (such as changing an “old man” to “Mr. Olsen”). I can’t find anything that lets the player refer to objects by names chosen by the player.
You’re headed in the right direction; you’ve just got some of the details wrong.
You don’t need to specify an “indexed text” anymore – you can just call it a “text”. Also, when you say “indexed text that varies,” it sounds like you’re creating a global variable. I’m pretty sure you can’t use a global variable as an understanding token; you have to use a property of the thing you’re referring to. So, something like this would work:
[code]Test Chamber is a room.
A hat is in the Test Chamber. The hat is wearable. The hat has some text called the color. The color of the hat is “plain”. The printed name of the hat is " hat". Understand the color property as describing the hat.
Before reading a command when the color of the hat is “plain”:
say “That hat’s pretty boring, actually. What’s your favorite color? [run paragraph on]”;
After reading a command when the color of the hat is “plain”:
now the color of the hat is the substituted form of “[the player’s command]” in lower case;
say “[line break]Ooh, nice choice. We’ll make the hat [color of the hat], then.”;
reject the player’s command;[/code]
If you have several things that need to be assigned colors, you’ll need to set each of them up with their own color property and assign them each individually when the player provides the input. If you have lots of color-assigned things, you may want to create a new kind.
YES! I think that worked. It took me a long time because I was also using an older version of Inform (oops) which wasn’t helping. It couldn’t understand some of what you were telling me to do. After pasting my code into the latest version, I had about a million punctuation issues to fix, but I got those taken care of and was able to adapt your solution to my code and it worked!!!
Thanks so much!!!
Hopefully the rest of my code will still work as designed…extensive testing coming up!
I suspected as much, since you kept using the term “indexed text”. In the current version of Inform, all text is indexed by default (or maybe it gets indexed dynamically whenever needed, I’m not 100% sure), so you can just call it “text”.