Choosing a character at the beginning of the game.

I’m working on a game loosely inspired by Maniac Mansion, in which you play as one of a group of people who each has different abilities. I want the player to be able to choose which of the characters they’ll start as (with the others being transported to a cell). The closest thing to this I could find in the documentation was instructions on choosing gender, when I altered in order to make a character select (I plan to change the default statements later), but ran into the problem of the game not letting the same word refer to both a character and a value. I reproduced the code that I’m using below – this code functions, in the sense that it compiles, but I have to change the ‘name’ value to something other than a person’s name, which obviously won’t be useful for the final version. Can anyone help?


Name is a kind of value. A person has a name. The names are Taffy1, Jackie1, Todd1, Mike1, and unknown.
The name of the player is unknown.

Jackie is a person.

Todd is a person.

Mike is a person.

Taffy is a person.

Character Select is a room.

When play begins:
now the command prompt is “Who are you? >”.

After reading a command when the name of the player is unknown:
if the player’s command includes “[name]”:
now the name of the player is the name understood;
if the name of the player is unknown:
say “This story requires a selection. [run paragraph on]”;
reject the player’s command;
if the name of the player is Taffy1, now the player is Taffy;
if the name of the player is Jackie1, now the player is Jackie;
if the name of the player is Todd1, now the player is Todd;
if the name of the player is Mike1, now the player is Mike;
say “[line break]Thank you. We now begin…”;
now the command prompt is “>”;
move the player to Cell 1;
reject the player’s command;
otherwise:
say “Sorry, we’re not ready to go on yet. [run paragraph on]”;
reject the player’s command.

Cell 1 is a room.

Cell 2 is east of Cell 1. Jackie, Todd, Mike and Taffy are in Cell 2.

Try this.

Alice and Claire are women. Bob and Dave are men.

After reading a command when the player is yourself: [default player character object]
    if the player's command matches "Alice":
        now the player is Alice;
    otherwise if the player's command matches "Bob":
        now the player is Bob;
    otherwise if the player's command matches "Claire":
        now the player is Claire;
    otherwise if the player's command matches "Dave":
        now the player is Dave;
    otherwise:
        say "Please select Alice, Bob, Claire, or Dave.";
    reject the player's command.

It’s not very elegant, but it’ll be easier to use if you only have a few characters to choose from.

This seems like a more extensible solution. You may want to flesh it out a bit more of course.

[code]Alice and Claire are women. Bob and Dave are men.

After reading a command when the player is yourself:
let x be the person matched in command;
if x is nothing, say “Please select Alice, Bob, Claire, or Dave.”;
otherwise now the player is x;
reject the player’s command.

Definition: a person is other if it is not the player.

To decide which object is the/-- person matched in command:
repeat with critter running through other people:
if the player’s command matches the text the printed name of the critter, case insensitively:
decide on the critter;
decide on nothing.[/code]

If you wanted an really rigorous implementation, you could create a new Choosing out-of-world action, then Understand “[selectable character]” as choosing when the player is yourself. That would allow synonyms and abbreviations instead of having to type the full name, although with this few characters that’s probably overkill.

[code]Alice and Claire are women. Bob and Dave are men.

Player-selecting is an action applying to one visible thing. Understand “[anything]” as player-selecting when the player is yourself.
Instead of doing something other than player-selecting when the player is yourself, say the choice.
To say the choice: say “Please select Alice, Bob, Claire, or Dave.”;
Check player-selecting when the noun is yourself: say the choice instead.
Check player-selecting a thing when the noun is not a person: say "That’s not even a person. "; say the choice instead.
Carry out player-selecting: now the player is the noun.

Home is a room. The World is a room. All women are in the world. All men are in the world. The rock is in the world.[/code]

You could make it an action. I have to confess, I can’t think of an Activity-based implementation that wouldn’t be cumbersome. Then again, I’ve yet to reach a point where making my own Activities seemed necessary.

That seems to work. Thanks for your help!