Need help creating action applying to unseen person

Okay, so I’m trying to create an action that allows the player to change which character they control at will. I need the action to apply to the named person, even if that person is not visible or touchable (since most puzzles will probably require the characters being in separate places). Here is the code I have so far.

[code]Defense Solicitor is a man. He is in Defense Solicitor’s Office.
Pompous Barrister is a man. He is in Pompous Barrister’s Office.
Studious Intern is a man. He is in Studious Intern’s Office.
The Wind is a person. It is in the precarious brick ledge.

Being is an action applying to one thing.
Understand “Be [something]” as being.

Check being something: if the noun is not a person, say “How often have you dreamed of being [the noun], but alas it cannot be.” instead.
Check being something: if the noun is the player, say “You are already yourself. It’s part of being you!” instead.

Carry out being Defense Solicitor: now the player is the noun; now the command prompt is "DS: ".
Carry out being Pompous Barrister: now the player is the noun; now the command prompt is "PB: ".
Carry out being Studious Intern: now the player is the noun; now the command prompt is "SI: ".
Carry out being The Wind: now the player is the noun; now the command prompt is "TW: ".

Report being something: say “You are now [the noun].”[/code]

I know the code isn’t perfect or especially elegant, but I’m not worried about that. I’m just want it to work so that regardless of the player’s location, they can become the Pompous Barrister by typing in “Be Pompous Barrister”.

Right now, the key issue is in this line:

Being is an action applying to one thing.

I just don’t know how to go about making the action able to apply to an untouchable, non-visible thing such as a person in another room.
When two characters are in the same room, this code works perfect for what I need.

I also have this little problem about getting rid of the “former self” generated by:

When play begins: now the command prompt is "DS: "; now the player is Defense Solicitor.

But that is less of an issue at the moment.

Oh, and this bit isn’t working either Report being something: say "You are now [the noun]."
But again, less important than the problem of performing the action.

You need to do two things here:

Being is an action applying to one visible thing. Understand "Be [any thing]" as being.

Note “visible” and “any thing.” “Visible” is actually anything the player can refer to, as opposed to “touchable.” (See 12.17 of the documentation.) The “[any thing]” token lets the player refer to any thing, not just things that are in scope. (See section 16.7 of the documentation.) Put these two things together, and now the player can type “Be x” to refer to x no matter where it is – whether the player can see it or not!

The use of “visible” here is super confusing and unfortunate, but the thing to keep in mind is that “visible” is actually much more permissive than the default; “visible” is anything the player can talk about, and in combination with “[any thing]” or “[any person]” often means things that aren’t, well, visible.

I don’t understand the former self object very well, but I think you can get rid of this by saying “The player is Defense Solicitor” (or whoever the player is at the start of the game).

The report rules are a tricky case; it looks to me as though what’s going on is that, since the player’s identity changes in the carry out stage, the report rule doesn’t fire, because it’s not reporting the player being anymore. (Someone who’s better informed may be able to correct me.) I noticed that this does fire:

Report an actor being: say "You are now [the noun]."

But unfortunately it always says “You are now yourself,” which is not enlightening.

I would actually get around this by folding it into the carry out rule. Currently that would mean that you’d have to write something for each of your four cases, and I think it really would pay off to write a general rule for “carry out being” so you could just say “You are now [the noun]” before becoming the noun, which should produce nicer output; but I can’t actually get my attempt to compile now, so I won’t try to boss you around too much.

Yes! This worked perfect! I think I’ll go read the chapter on scope, I kinda scanned past that one :confused:

After posting, I got rid of the former self by starting the game in a disconnected room called ‘limbo’, so that he got left behind after the change in character occurred. However, simply putting “The player is Defense Solicitor” at the start works better, so I’m going with that.

I’ll go with that, it’s not too difficult and I think once all is said and done there will only be maybe 6 characters total.
Although, now that all those bits are working, I just realized I should probably put in an automated ‘Look’ command there so the player knows where the new character is. Back to work!

I got my version to work (and have added in the automatic look that you suggested). The problem was, embarrassingly, a stray double quote mark; also I was trying to write “his prompt” or “the defense solicitor’s prompt” when “The prompt of the defense solicitor” is required. I’ve put it in the spoiler:

[spoiler][code]Defense Solicitor’s Office is a room. Pompous Barrister’s Office is a room. Studious Intern’s Office is a room. The Precarious Brick Ledge is a room.

A person has some text called the prompt. The prompt of a person is usually “>”.
Defense Solicitor is a man. He is in Defense Solicitor’s Office. The player is Defense Solicitor. The prompt of Defense Solicitor is “DS:”.
Pompous Barrister is a man. He is in Pompous Barrister’s Office. The prompt of Pompous Barrister is “PB:”.
Studious Intern is a man. He is in Studious Intern’s Office. The prompt of Studious Intern is “SI:”.
The Wind is a person. It is in the precarious brick ledge. The prompt of The Wind is “TW:”.
The pen is in studious intern’s office.

Being is an action applying to one visible thing.
Understand “Be [any thing]” as being.

Check being something: if the noun is not a person, say “How often have you dreamed of being [the noun], but alas it cannot be.” instead.
Check being something: if the noun is the player, say “You are already yourself. It’s part of being you!” instead.

Carry out being: say “You are now [the noun].”; now the player is the noun; now the command prompt is the prompt of the noun; try looking.[/code][/spoiler]

Incidentally, you can restrict the command to people by changing “[any thing]” to “[any person]”; but then “be pen” will yield the dread “That noun did not make sense in that context” default response, so your approach is probably better as it lets you write your own response. Also, if you don’t want every person to be playable, you can set a property for which people are playable and then restrict your check rule accordingly (“A person can be playable. If the noun is not a playable person…” or something like that).

Oh wow! This is far more elegant then the brute force approach I was trying. I think I’ll attempt something like this for some of my other custom commands as well :smiley:

I decided I wanted to tell the player who they are last, after looking, so I just moved the line to the end and changed it to “You are now the [printed name of the noun]” and it works perfectly.

I considered using [any person], but decided I wanted a more customized response. However, I like that playable/unplayable rule far better, as it allows me to make some actors that cannot be played yet are not specifically isolated.

I decided to go with this:

A thing can be playable or unplayable or inanimate. A thing is usually inanimate. The Defense Solicitor is playable.
This allows me to make separate check rules for unplayable people and inanimate objects. Any new actor will simply be identified as playable or unplayable.

Check being something: if the noun is inanimate, say "How often have you dreamed of being [the noun], but alas it cannot be." instead. Check being something: if the noun is unplayable, say "Try as hard as you might, you'll never be like [the noun]".

I may draw up a table of random descriptions, so that every time you try to be an unplayable thing you get a random reason from a list of a dozen or so. This would also allow me to cut down the code to either playable or unplayable, so I only need to specify playable characters. Technically I could do that with only 1 description, but I like variety. I already have 3 other random tables used purely for adding spice, so one more wouldn’t hurt!

Variation is certainly good.
I’m pretty sure that even though you understand “Be [any thing]” as being, you can replace «A thing can be playable or unplayable or inanimate. A thing is usually inanimate.» with

A person can be playable or unplayable. A person is usually unplayable.

and «Check being something: if the noun is inanimate, say “How often have you dreamed of being [the noun], but alas it cannot be.” instead.» with

Check being something: if the noun is not a person, instead say "How often have you dreamed of being [a noun], but alas it cannot be."

And then you need not trouble yourself with specifying which persons are unplayable.

Or if you want to save yourself a property and possibly some typing, you can do this:

Definition: A person is unplayable rather than playable if the prompt of it is ">".

Thanks for all the help guys! I think I’m going to go with something like this (unless an easier way to achieve the same effect can be found):

[code]
A person has some text called the prompt. The prompt of a person is usually “>”.
A thing is either playable or unplayable. A thing is usually unplayable.

Check being something: if the noun is unplayable, say “How often have you dreamed of being [the noun], but alas it cannot be.” instead.
Check being something: if the noun is the player, say “You are already yourself. It’s part of being you!” instead.

Carry out being: if the noun is a person begin; now the player is the noun; now the command prompt is the prompt of the noun; say “[conditional paragraph break]”; try looking; say “You are now the [printed name of the noun].”; end if.

Carry out being: if the noun is not a person, say “[conditional paragraph break][bold type][printed name of location of noun][roman type][line break][description of location of noun][paragraph break]You can see [list of anything in location of noun][paragraph break]You are now [the noun]. Unfortunately, being an inanimate object, all you can do is sit here. Inanimate.[paragraph break][The noun]: Be [printed name of player][paragraph break]==>[paragraph break]”.[/code]

Note that I explicitly kept “A thing is either playable or unplayable.” instead of making it a person. This is so I can choose to make certain non-person things ‘playable’. The reason for this is entirely frivolous, except that it could be used as a way of remote viewing a situation. The story will be laid out in such a way to encourage the player to attempt Being certain inanimate objects.

Here is what it looks like in-game:

I know the audience this game is being made for will definitely try commands like that, so it is not wasted time to implement such a response. Foremost this game is a practice run to get a hang of the language, but it is also a fangame of sorts so I’m implementing custom commands I know other fans would want to see.