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?
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 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?
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:
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.
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).
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.
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?
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.
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.)
(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!)
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âŚ)
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
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.