Renaming objects

I want to create a dynamic object with various properties on the fly. The hardest part is the name of the object. I created a person->adventurer named Z:

An adventurer is a kind of person. 
A fighter, cleric, scout, and magician are kinds of adventurers.
Z is a male fighter. [template character]

Later, the player can rename the adventurer.
I can change the printed name but when I input SHOWME it says no object exists, but SHOWME Z does work.
Is it possible to rename an object so that the SHOWME command recognizes it?

Do you mean you want the name the player types in to be recognized by the parser as referring to the player-object? If that’s the case, I think this example in the docs has you covered.

1 Like

Fido looks good but I can’t get it to compile. Here’s the code:

An adventurer is a kind of person. 
Z is an adventurer in the Lobby.
The advname of Z is "nothing".
Understand the advname property as describing an adventurer.

An adventurer has some text called advname.
An adventurer has a gender.
An adventurer has some text called class.
An adventurer has a number called dex.

[Assigning the name from the player to the adventuer.]
Rule for printing the name of the adventurer when the advname of the adventurer is not "nothing":
	say "[advname of adventurer]".

I get the error In ‘Rule for printing the name of the adventurer when the advname of the adventurer is not “nothing”’.
It also seems to have problems with the object Z (adventurer) and its kind.

The compiler error is because the rule refers to “the adventurer”, but there’s no such thing as “the adventurer”; you’ve set it up as the name of a kind, so it doesn’t know which adventurer you mean. Try:

Rule for printing the name of an adventurer when the advname is not "nothing":
	say "[advname]".

What are the second set of issues you’re having?

I’m having trouble trying to instantiate an adventurer and allowing the player to name that adventurer. With the changes I added, it compiles but throws a runtime error after I enter the name.

 Run-time problem P10: Since nothing is not allowed the property "advname", it is against the rules to try to use it.

I want to create an adventurer (without a name) and give have the player give it a name plus other properties. I use the template character Z but then it stays that way, and EXAMINE MyName doesn’t work.

An adventurer is a kind of person. 

[Template character to be renamed and reused.]
Z is an adventurer in the Lobby.
The advname of Z is "nothing".
Understand the advname property as describing an adventurer.
An adventurer has some text called advname.

[Assigning the name from the player to the adventuer.]
Rule for printing the name of the adventurer when the advname is not "nothing":
	say "[advname]".

Data is a kind of value. The data are stName, stSex, stClass, stDex, and complete.
Stage is data that varies.

After looking for the first time:
	now stage is stName;
	now current question is "";
	now current prompt is "What is the name of the character? ";
	now punctuation removal is true;
	ask an open question, in text mode;
    
A text question rule when stage is stName:
	now the advname is the current answer;
	now the printed name of Z is the current answer;
	now stage is stSex;
	exit.

I am confused.

I think you’re using an extension that I haven’t messed around with (Questions by Michael Callaghan, maybe?) so there could be other things going on that I’m not aware of, but I wonder whether the issue is this line:

now the advname is the current answer;

Similar to the previous issue you were running into, I suspect “the advname” isn’t giving the compiler enough to go on. Does subbing in “Now the advname of Z is the current answer” improve things?

1 Like

Yes, I cannot use advname by itself. It must be advname of Z, the property of an object.
I changed that and it worked for SHOWME and EXAMINE.
I wanted to avoid making a concrete object (Z) and overwriting it, but since I can do that for name and printed name, it looks like a statically created object.
The output looks like this:


It use to say Z for the name and printed name, which means the player could not access the adventurer by this name he/she gave.

I have a trivial related question. I create an adventurer Alethea with a Feminine gender, but when I SHOWME Aletha, I get a gender Feminine in the list, but male in the property list.


Notice the property list:

unlit, inedible...male;...

but below

gender: Feminine

What’s up with that?

You’re creating them as a generic person, right, and then adding properties on top of that? So “gender” is a property you’ve created? A generic “person” is I think male, so that’s probably what’s going on. There might be extensions to deal with this, or you might just want to ask for gender first, and then swap in either a pre-created generic man or generic woman and apply the rest of the modifications to them, I suppose – though since this is the PC, I’m not sure how frequently it actually matters what Inform thinks their gender is (I assume you’re using your user-created gender property already).

1 Like

Inform by default supplies “male”, “female”, “neuter” as properties of the “person” kind, which are used for setting pronouns and such. If you want to use your own system for gender, you’ll want to overwrite or modify the default one.

1 Like

You could just say now Z is female though. The only downside is that Z won’t be considered to be “a woman” even though she is female, since you can’t change the kind at runtime… but if you just make a habit of saying “male person” or “female person” instead of “man” or “woman” respectively, that might not matter?

3 Likes

I thought this might be the case. A person has a default gender that cannot be changed. I had to add a property ‘gender’ to assign it on the fly. I tried not adding a property ‘gender’ but then it wouldn’t compile. I would prefer that the default property was the same as the added one. The inconsistency makes me think that something is going to come out of the swamp later and bite me.

Sure it can!

Instead of touching a person:
    if the noun is male, now the noun is female;
    otherwise now the noun is male;
    say "The gender of [the noun] has been changed!"

No, it doesn’t work. Compile error on trying to access gender without a property explicitly set to gender.

[An adventurer has a gender.]
A gender question rule:
	if the gender understood is Neutral:
		say "Your adventurer is either male or female, Try again.";
		retry;
	now the gender of Z is the gender understood;
	now stage is stClass;
	exit;

If I add the gender property (commented out above), then it works but with the SHOWME Z inconsistency.

Yeah, the Standard Rules don’t name that property “gender”. So you have to say explicitly “…is male” or “…is female”. (Or “…is neuter” if you have quirky animal sidekicks.)

2 Likes

Finneas Flatworm is here to save the day!

(I guess they’re more hermaphroditic than neuter but Inform doesn’t handle that well out of the box; gotta file a bug so Graham fixes that in the next release!)

1 Like

Yeah, one of my long-term desiderata for Inform is a better system for handling pronouns, since right now it’s incredibly difficult out-of-the-box to handle anything besides standard male/female/neuter. Suppose you want a cat that can be called either “he” or “it”—Inform can’t handle it, you have to pick one or the other. (Or a ship that’s “she” or “it”, or a mysterious figure who’s “he” or “she” because the player doesn’t know their gender—Infocom did this one! Or anything at all involving singular “they”.)

(One of the sources I’m quoting in my research is pretentious enough to talk about den Desideraten all the time and now I’m doing it…)

1 Like

That would definitely be a really great improvement, and sorry if I at all came across as flippant about the broader point - I know you were just referencing Inform’s (to my ear odd) convention of using “it” for animals in the last bit of your post, and the idea of specifically-asexual/hermaphroditic animal sidekicks just popped into my head and amused me :slight_smile:

Nah, I get it! I was also making a joke about how a classic D&D adventurer would ever be “it” (since “they” isn’t at all supported).

1 Like

That’s what I meant when I wrote in the other thread:

So you could either modify the gender question rule to set Z to female (with now ... is female, as people said) if the player answered feminine:

A gender question rule:
	now the gender of Z is the gender understood;
	if the gender of Z is feminine:
		now Z is female;
	now stage is stClass;
	exit;

… or just forgo the extension’s specific way of asking the gender question and offer a menu question instead (a different type of question which the extension provides) to let the player choose the character’s gender by a numbered menu option:

Every turn when stage is stSex:
	say "What is the gender of the character?";
	now current question menu is {"male", "female"};
	now current prompt is "Enter the number of an option: ";
	ask an open question, in menu mode;

A menu question rule when stage is stSex:	
	if the number understood is 2:
		now Z is female;
	now stage is stClass;
	exit;

I left out the case where the number understood is 1, because in the example code from the other thread, there’s a male template character as the default, so no change needed in that case.

Output:

What is the name of the character? Kate
What is the gender of the character?
1 - male
2 - female

Enter the number of an option: 2
What is the class of the character? cleric

Okay, you created Kate, female cleric, with a dexterity of 17.

(I didn’t add non-binary or other options for the moment, because as mentioned above, Inform wouldn’t really do much with that information. But of course, it would be easy to add them to this choice menu if desired.)

As an alternative to “now Z is female”, you could swap in a female template character, as Mike mentioned.

2 Likes