Player properties ["Yourself" vs "The Player, etc]

It seems that the player (person) has some special properties not the same as a generic person. I want to create an adventurer that is a person with many text and number properties, but the compiler doesn’t seem to want me to make the player an adventurer.

An adventurer is a kind of person.
The player is an adventurer.

I gave up on that and went with

The player has some text called advName.
The player has some text called advGender. [Supercedes default gender.]
The player has some text called class.
The player has a number called dex.

Trait is a number that varies. Trait is 0.
MAXTRAIT is always 18. 	
MINPRIMTRAIT is always 12.
MINSECTRAIT is always 8.

I am having trouble with The player has a number called dex..
Can a player be assigned a numeric property like this?

Yes. I’m having no trouble with your code. What error are you getting?

This works.

An adventurer is a kind of person.
Yourself is an adventurer.

The trouble is somewhere else in your code, maybe another use of dex somewhere.

2 Likes

No. the player is not a thing. It is a thing variable. You can change the player at runtime to any person you want.

You can assign the player numeric properties, of course. In fact, all of the code you showed in your opening post works if used on a person rather than a variable. If you have no need to switch players at runtime, you can just make use of the default person that Inform creates to fulfill the role of player… but that default person is not the player but rather yourself.

So instead of this:

An adventurer is a kind of person.
The player is an adventurer.

The player has some text called advName.
The player has some text called advGender. [Supercedes default gender.]
The player has some text called class.
The player has a number called dex.

I’m pretty sure has some text is also going to fail here? Because you can’t give properties to a variable. But the following almost identical code should work:

An adventurer is a kind of person.
Yourself is an adventurer.

Yourself has some text called advName.
Yourself has some text called advGender. [Supercedes default gender.]
Yourself has some text called class.
Yourself has a number called dex.

I’m guessing you actually want those last 4 lines to be adding properties to an adventurer, rather than the player, and of course that will work too.

1 Like

I think you’ll find that “the player” works fine for assigning properties. You just can’t use it to change the kind.
This is the error I get from the original code:

Problem. Before reading ‘The player is an adventurer’ I already knew that ‘player’ is a person, and it is too late to change now.

If you just change that one line, the rest of the code works fine:

An adventurer is a kind of person.
Yourself is an adventurer.

The player has some text called advName. The advName of the player is "Fred".
The player has some text called advGender. The advGender of the player is "male".
The player has some text called class. The class of the player is "rogue".
The player has a number called dex. The dex of the player is 18.

>SHOWME ME
yourself - adventurer
location: in the Alley
unlit, inedible, portable; transparent, male; singular-named, proper-named
description: “As good-looking as ever.”
initial appearance: none
carrying capacity: 100
printed name: “yourself”
printed plural name: “adventurers”
indefinite article: none
list grouping key: none
advName: “Fred”
advGender: “male”
class: “rogue”
dex: 18

2 Likes

I appreciate your assistance but I’m not sure I understand some of these nuances. I though 'Yourself" was the player. Also I will have NPC’s who are adventurers, and I want to compare their properties withe the player’s properties. For example, is Alice’s Dex greater than the player’s dex? So I think I need an adventurer kind.

I removed the lines

An adventurer is a kind of person.
The player is an adventurer. 

and it compiles fine, but then leaves open the question about how to compare the player with NPC’s.

Given that the player is not an adventurer, but the other lines are fine,
I have a problem with comparing dex with the numerical constants.

[This must be adjusted AFTER the traits are generated.]
This is the gender-adjustment rule:
	if advGender is "female":
		increment Dex;
		if Dex is greater than MAXPRIMTRAIT:
			now Dex is MAXPRIMTRAIT;

I get the compile error:

 You wrote 'increment Dex' [![](blob:https://intfiction.org/7dd886bb-cb73-4f84-a905-568d1fb66ae8)](source:story.ni#line118), but 'Dex' is a value, not a place where a value is stored.

which is error message I do not understand or its explanation.
What’s wrong with incrementing a number?

I also get an error on the if Dex is greater... pair of lines. It seems
I do not understand how to use Dex property or number constants.

This looks good, but i am totally confused between the player (an instance of the Person kind) and Yourself (an instance of the Person kind?). I can “showme player” or “showme yourself” and get a non-object error message despite declaring Yourself in the code, but “showme self” gets the expected object description. What is the difference?

Player is a variable - technically, a person that varies. That allows you to do stuff like say “now the player is Alice” for a game where the player character shifts over time. “Yourself” is a person object that Inform creates as the default value of the “player” variable. It’s a little confusing but just remember that “yourself” is the object and “the player” is a pointer to them if it gets confusing (though as others have said, Inform does let you be a little sloppy about the distinction).

The issues around Dex really make it look like you’ve defined it elsewhere in your code in an incompatible way; I’d try to ctrl-f through your source to track that down, or if that doesn’t work create a copy of your code and start cutting things out until you’ve got minimal example that repeats the bug, and post that here.

1 Like

Mike,
Yes, that makes it clearer, but I have already stripped down the code. This is the full code:

"Character Generator" by Clyde Falsoon

Include Questions by Michael Callaghan.

[Enable the Rules tracing option from the code.]
To turn on rules tracing:
	(- RulesOnSub(); -);

An adventurer is a kind of person.

An adventurer has some text called advName.
An adventurer  has some text called advGender. [Supercedes default gender.]
An adventurer  has some text called class.
An adventurer  has a number called dex.

Yourself is an adventurer. Fred is an adventurer.

Trait is a number that varies. Trait is 0.
MAXTRAIT is always 18. 	
MINPRIMTRAIT is always 12.
MINSECTRAIT is always 8.

Understand the advname property as describing yourself.


Data is a kind of value. The data are stName, stSex, stClass, complete, and paused.
Stage is data that varies. Stage is stName.
	
[Assigning the name from the player to the adventuer.]
This is the adventurer-printing rule:
	say "[advname of player] ([dex of player], [advGender of player])";
	

Lobby is a room. 
Description of Lobby is "Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams.".

[Set the initial stage.]
When play begins:
	now stage is stName;

Every turn when stage is stName:
[	turn on rules tracing;]
	follow the name catching rule;

[Assign the adventurer's name.]
This is the name catching rule:
	now current question is "";
	now current prompt is "By what name shall you be called, young adventurer? ";
	now punctuation removal is true;
	ask an open question, in text mode;
    
A text question rule when stage is stName:
	now the advname of player is the current answer;
	now the printed name of player is the current answer;
	now stage is stSex;
	exit.

[Assign the adventurer's gender.]
Every turn when stage is stSex:
	now current prompt is "What is your gender? (M/F)";
	ask a closed question, in gender mode;

A gender question rule:
	if the gender understood is Neutral:
		say "You are either male or female. Try again.";
		retry;
	say "the gender understood is [gender understood]"; 
	if the gender understood is Feminine:
		now advGender is "female";
	else:	
		now advGender is "male";
	now stage is stClass;
	exit;

Yourself is a specific instance of the person kind. The player is a person variable.
You couldn’t say:

A box is a kind of container.
The package is a container variable.
The package is a box.

No object has been created there… box is the name of a kind. package needs to be assigned some particular instance of a container (or a subkind of container, like, say, some particular box).

You could say:

A box is a kind of container.
The package is a container variable.
The parcel is a container.
The parcel is a box.
The package is the parcel.

You can have redundant assertions where one is more specific; just you can’t have contradictory ones. You could say (in any order):

Foo is a vehicle.
Foo is an object.
Foo is a container.
Foo is a thing.

and it would compile, and Foo would be a vehicle (which is a container, which is a thing, which is an object). So saying both that the parcel is a container and the parcel is a box is fine.

The Standard Rules have:

The yourself is an undescribed person. The yourself is proper-named.

The yourself is privately-named.
Understand "your former self" or "my former self" or "former self" or
        "former" as yourself when the player is not yourself.

The description of yourself is usually "As good-looking as ever."

[...]

The player is a person that varies.

The privately-named there is why you can’t use “yourself” in commands to refer to the yourself object. You can use “self”, “me”, “myself” (as defined in the Command Parser Kit).

It doesn’t explicitly say there:

The player is yourself.

if it did, you couldn’t say

Bob is a person.
The player is Bob.

because you can’t assert that the same variable is two different things. (“assertions” are all the code that isn’t within a definition, or rule, or to-phrase.) But if you have an object variable you haven’t explicitly defined, it is automatically assigned the instance of that kind whose existence was asserted first. yourself is always the first person created, so person variables, including player, default to yourself.

Anyway,

An adventurer is a kind of person.
The player is an adventurer.

is like this case:

A box is a kind of container.
The package is a container variable.
The package is a box.

It’s a special case that this works:

The player has some text called advName.

With ordinary variables, that wouldn’t. This fails:

A box is a kind of container.
The package is a container variable.
The parcel is a container.
The parcel is a box.
The package is the parcel.
The package has a text called the address.

This would work:

The parcel has a text called the address.
2 Likes

I’m on my phone today so can’t test that, but I don’t see anywhere where Dex is initialized or tested, so is there anything else that needs to be in the sample to demonstrate the error?

You need to tell Inform whose property it is:

... Dex of the player ...

The same goes for advGender, which should be advGender of the player.

(Also, just to be sure: you’re using MAXPRIMTRAIT there, but in the longer code excerpt three posts down you don’t define that; there are only MAXTRAIT and MINPRIMTRAIT.)

1 Like

I tried the ‘dex of the player’ and got the same error.
I tried initializing dex and got a similar error.

Here’s my goal: I want the person who enters commands on the keyboard to grow their adventurer–I will have tons of properties for the adventurer–but I don’t know if that is Yourself or the player or a user-defined Person. Which one should I use?

Yes, StJohn, adding ‘dex of the player’ is the solution, and ‘advGender of the player’ works. I think it didn’t work before because I didn’t have the specific Yourself or ‘the player’ object to receive the properties.

OK. I got this code to work for a name.

An adventurer is a kind of person.
Yourself is an adventurer.

The player has some text called advName.
The player  has some text called advGender. [Supercedes default gender.]
The player  has some text called class. The class of the player is "none".
The player  has a number called dex. The dex of the player is 0.

Trait is a number that varies. Trait is 0.
MAXTRAIT is always 18. 	
MINPRIMTRAIT is always 12.
MINSECTRAIT is always 8.

Understand the advname property as describing yourself.

By the looks of this, I will be piling on ‘the player’ with some text, or a number, or other properties (can I call them properties?). I’m ok with that. How does that affect Yourself?

I want to understand this Yourself/player relation. The player is a variable to a Person object. Yourself is the object to which the player points. Right? So when creating objects, I need to use Yourself, but I can add properties to the player (e.g. dex) which will attach to the Yourself object?

Inform is telling you to define the Dex property as a number that varies.

The player has a number called dex. The dex of the player is usually 0.

The statement “The player has a number called dex” implies a constant. Initializing the number with “usually” tells inform that it’s a variable.

1 Like

No, I thought that this worked. After creating (something) with advName Alice and advGender feminine, I could not ‘x alice’: There seems to be no object anywhere in the model world. If I showme alice; same thing. If I showme self, then I get Yourself descriptions. Why is this so hard? Am I trying to do something that INFORM was not meant to do: create a person with attributes? (I feel concussed.)

Do you have a minimal example that shows the wrong behaviour (where “x alice” doesn’t work)?

I’m asking because it does work with the version of the code which you posted further above. It’s enough that the person has the advName property and that you’ve got the line

Understand the advname property as describing an adventurer.

(For general use, including yourself if we also have “Yourself is an adventurer.”, as given above.

Understand the advname property as describing yourself.” will work, too.)

Here is the code that I can just barely get to compile. It passes my level of understanding.

"Character Generator" by Clyde Falsoon
Include Questions by Michael Callaghan.

The player has some text called advName. 
The player has some text called advGender. [Supercedes default gender.]
The player has some text called class. 
The player has a number called dex.

[Understand the advName property as describing an adventurer.]

MAXTRAIT is always 18. 	
MINPRIMTRAIT is always 12.
MINSECTRAIT is always 8.

Data is a kind of value. The data are stName, stSex, stClass, complete, and paused.
Stage is data that varies. Stage is stName.
	
[Assigning the name from the player to the adventuer.]
[Rule for printing the player is:
	say "[advName of player] ([dex of player], [advGender of player])";
]

Lobby is a room. 
Description of Lobby is "Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams.".

[Set the initial stage.]
When play begins:
	now stage is stName;

Every turn when stage is stName:
[	turn on rules tracing;]
	follow the name catching rule;

[Assign the adventurer's name.]
This is the name catching rule:
	now current question is "";
	now current prompt is "By what name shall you be called, young adventurer? ";
	now punctuation removal is true;
	ask an open question, in text mode;
    
A text question rule when stage is stName:
	now the advName of player is the current answer;
	now the printed name of player is the current answer;
	now the player is in the lobby;
	now stage is stSex;
	exit.

[Assign the adventurer's gender.]
Every turn when stage is stSex:
	now current prompt is "What is your gender? (M/F)";
	ask a closed question, in gender mode;

A gender question rule:
	if the gender understood is Neutral:
		say "You are either male or female. Try again.";
		retry;
	say "the gender understood is [gender understood]"; 
	if the gender understood is Feminine:
		now advGender of player is "female";
	else:	
		now advGender of player is "male";
	now player is in lobby;
	now stage is stClass;
	exit;

Please note a couple things:
(1) I had to comment out: “Understand the advName property as describing an adventurer.” because it wouldn’t compile.
(2) I would like the printing rule to work, but couldn’t get it to compile.
(3) After the adventurer was named (Barak) and genderized, I put him in the lobby. He does not show up nor can I EXAMINE BARAK.
Attached is a screen shot.

This is a sandbox. Can I just trash it and start over with a simpler approach? I don’t understand the problem. Should I not try to attribute ‘the player’? Should I create and attribute Person but then how can the user play as an attributed Adventurer?

In this excerpt you haven’t defined “adventurer” as a kind of person (nor is the player character an adventurer) so that’s why you’re getting this error; meanwhile, the lack of this line is why BARAK isn’t being understood as referring to the character.

When do you want this to be printed out? “For printing the player” isn’t an activity that exists; do you just want it to be the printed name or is there something else you’re looking to do?

I don’t know the Questions extension well, but the way the room description is reprinting in the middle of the questions is a bit awkward – it might be worth trying to suppress that. EDIT: oh wait, that’s because you’re moving the player to the lobby (where they already are) immediately after they input a name?

1 Like