Value and Player/Character Question

Hello!

I’m new to Inform 7 and I’m a bit stumped. I tried searching the forums for replies too but I haven’t seen the topic posted before.

I’m trying to get values displayed when the player inputs “stats”. Here is my code…

Requesting Stats is an action applying to nothing. Understand “stats” and “stat” and “statistics” as Requesting Stats.
Carry out requesting stats:
say “STR: [Strength][line break]AGL: [Agility][line break]INT: [Intelligence][line break]BEAU: [Beauty][line break]IMG: [Image][line break]FOR: [Fortitude][line break]FER: [Fertility][line break]SLP: [Sleep][line break][paragraph break]”;

Which is fine for numeric/integer values. But I’m trying to display these as well…

Powers is a kind of value. Limited Invisibility, Limited Telekinesis, Gifted Strength, Gifted Agility, Gifted Intelligence, Limited Sonic Blasts, Limited Shields are powers.

Negative Traits is a kind of value. Nightmare Prone, That Normal Life, Expensive Heroing, Weakness, Public Menace, Not Normal are negative traits.

However…

say “STR: [Strength][line break]AGL: [Agility][line break]INT: [Intelligence][line break]BEAU: [Beauty][line break]IMG: [Image][line break]FOR: [Fortitude][line break]FER: [Fertility][line break]SLP: [Sleep][line break]POW: [Powers][line break][paragraph break]”;

The BOLD section isn’t working or rather won’t display the variable. I assume a different set-up is needed for it? But I can’t find anything about displaying non-numeric variables.


The other question I had was about displaying a Player description and filling it with variables. Like, for example…

You are...
      if Beauty = 0 
          say, "quite hideous!"
     if Beauty = 1
          say, "kind of ugly..."

and so on. Would anyone know the best way of how I should go about setting this up?

Anonynn.

1 Like

Off the top of my head I don’t know anything about the first part BUT I can answer the second, easier part.

You can match the values of your beauty variable to text descriptions in a table.

Player-beauty is a number that varies.

Instead of rubbing the player: ["rubbing" is the action that gets triggered by the verb WASH]
	say "You try to clean up.";
	increment player-beauty.

Instead of examining the player:
	choose row with level of player-beauty in Table of Beauty Descriptions;
	say "You are [descriptor entry][paragraph break]"
	
Table of Beauty Descriptions
level	descriptor
0	"quite hideous!"
1	"kind of ugly..."
2	"totes gorge."

The important part is the last two sections: “choose row with [column title] of [the variable you care about] in [name of the table]” is the syntax for picking a row—which I frequently forget, and I type “choose row in [table name] with [column] of [value]” and then my project doesn’t compile.

If such a line attempts to pick out a line of the table that doesn’t exist—like if you keep on cleaning yourself in this game until your beauty is higher than 2 and then examine yourself—you’ll get a runtime error. So, take steps to prevent that!

About the first question, displaying non-numeric values isn’t a problem. If you’ve defined Powers as a kind of value in that way, when you ask Inform to say a Powers, it’ll just print its name.

What looks like the problem to me is that you’re trying to get Inform to say “Powers,” which is the kind of value–which makes it seem as though you haven’t defined a Powers-valued variable. If you just define Powers as a kind of value and then try to say “[Powers]”, it’s sort of like you said “[Number]”–Inform won’t know which Powers you mean.

What you can do is something like this:

Powers is a kind of value. Limited Invisibility, Limited Telekinesis, Gifted Strength, Gifted Agility, Gifted Intelligence, Limited Sonic Blasts, Limited Shields are powers.

Blessing is a Powers. 

and then you can say “POW: [Blessing]” and it’ll show the Powers you’ve set Blessing to. So Powers is the kind, but Blessing is the name of the variable and something you can say.

Another thing you could do is this:

The player has a Powers.

and then you could say “[Powers of the player]” and that would give you the value of the player’s Powers-valued property. (And you could make every person have a Powers this way, if you chose.)

That worked out great so far, thank you so much for your time. Is there a way to add other tables to that though…for example, I have.

Player-Beauty is a number that varies. Player-Beauty is 0.
Instead of examining the player:
	choose row with level of player-beauty in Table of Beauty Descriptions;
	say "Your face is [descriptor entry] when compared to most others."
	
Table of Beauty Descriptions
level	descriptor
0	"quite hideous"
1	"relatively unattractive"
2	"very plain and forgettable. Average really"
3	"attractive with a couple of cute attributes"
4	"very cute and attractive with several sensational attributes. Your femininity shines"
5	"incredibly attractive with several heart-breakingly perfect attributes"
6	"totally gorgeous with jaw-dropping beauty and hypnotic allure"
7	"flawless. It's extremely feminine; jaw-droppingly beautiful and hypnotic to stare at; men and women want nothing more than to kiss you and stare into your eyes. In fact, your face is almost otherwordly"

which prints:
Your face is quite hideous when compared to most others.

But I would like it to do something like…
Your face is quite hideous when compared to most others.
Your intelligence is far below average.

So I thought to create another table…

Player-Intelligence is a number that varies. Player-Intelligence is 0. 
Instead of examining the player:
	choose row with level of player-intelligence in Table of Intelligence Descriptions;
	say "You're [descriptor entry]."
	
Table of Intelligence Descriptions
level	descriptor
0	"far below average"
1	""
2	""
3	""
4	""
5	""
6	""
7	""

But it only prints the Player-Beauty during play.

Anonynn.

Thanks for your reply and help so far. I’m still having trouble with it though.

When I tried…

Powers is a kind of value. Limited Invisibility, Limited Telekinesis, Gifted Strength, Gifted Agility, Gifted Intelligence, Limited Sonic Blasts, Limited Shields are powers.

Blessing is a Powers. 

It said Blessing and Powers were the same and conflicting. So I tried this instead…

Powers is a kind of value. Limited Invisibility, Limited Telekinesis, Gifted Strength, Gifted Agility, Gifted Intelligence, Limited Sonic Blasts, Limited Shields are powers.

The player has a Powers.

Carry out requesting stats:
say “STR: [Player-Strength][line break]AGL: [Player-Agility][line break]INT: [Player-Intelligence][line break]BEAU: [Player-Beauty][line break]IMG: [Player-Image][line break]FOR: [Player-Fortitude][line break]FER: [Player-Fertility][line break]SLP: [Player-Sleep][line break]POW: [powers][line break]CUR: [negative traits][line break][paragraph break]”;

but it prints…

>stats
STR: 0
AGL: 0
INT: 0
BEAU: 0
IMG: 0
FOR: 0
FER: 0
SLP: 0
POW: 
*** Run-time problem P31: Attempt to use a property of the 'nothing' non-object: property powers

<illegal powers>
CUR: <illegal negative traits>

Even though Powers and Negative Traits are set up the same exact way. They just haven’t been defined yet.

Anonynn.

Ugh, I messed up the first thing. You need to say:

Blessing is a Powers that varies.

or

Blessing is a Powers variable.

This will define Blessing as a variable whose value will be a Powers, and then you can change it, print it, etc. (See §4.12 of the documentation.)

For the second approach, you would need to say “[powers of the player]” instead of just “[powers]”. That way Inform knows that it’s looking at a property of the player. (It would be safe to say “[powers]” when you were setting another property of the player–specifically, in the description of the player–but in an action rule like this, Inform doesn’t know which powers to look at.)

Your tables are set up just fine. The problem is that you have two different Instead of examining the player: rules. The game can only follow one of them! (I think that the compiler favors the rule that appears last in the source text, but don’t quote me on that.) So you’ll need to consolidate them into a single rule that refers to both tables.

This is a little tricky because a rule can only be “looking at” one table row at a time. We can’t write it like

Instead of examining the player:
	choose row with level of player-intelligence in Table of Intelligence Descriptions;
	choose row with level of player-beauty in Table of Beauty Descriptions;
	say "You're [descriptor entry] and [descriptor entry]."

That’ll just print the descriptor of the current player-beauty twice. (As soon as we choose another row, the rule forgets all about the row it was looking at before.) So we need to store some text in mid-rule:

Instead of examining the player:
	let int-descriptor be text;
	choose row with level of player-intelligence in Table of Intelligence Descriptions;
	now int-descriptor is "[descriptor entry]";
	let beaut-descriptor be text;
	choose row with level of player-beauty in Table of Beauty Descriptions;
	now beaut-descriptor is "[descriptor entry]";
	say "Intelligence-wise, you're [int-descriptor], and appearance-wise, you're [beaut-descriptor]."

I forget the internal name for variables like beaut-descriptor and int-descriptor, but because they’re declared in the middle of the rule, they only exist while that rule is being put through its paces. So you won’t be able to refer to beaut-descriptor in another rule without defining it again.

now int-descriptor is "[descriptor entry]";

As a side note, I see this a lot. It works, but it’s both faster and tidier to write

now int-descriptor is descriptor entry;

The descriptor entry is a text, so you can assign it to int-descriptor. You don’t have to create a new text that contains only descriptor entry as a substitution.

Temporary variables (chapter 11.15).

1 Like

Hm, unfortunately, those are throwing errors. I have…

say "Your face is [beau-descriptor] when compared to most others."

and

Instead of examining the player:
	let beaut-descriptor be text;
	choose row with level of player-beauty in Table of Beauty Descriptions;
	now beaut-descriptor is "[descriptor entry]";

as well as…

Player-Beauty is a number that varies. Player-Beauty is 0.
Table of Beauty Descriptions
level	descriptor
0	"quite hideous"
1	"relatively unattractive"
2	"very plain and forgettable. Average really"
3	"attractive with a couple of cute attributes"
4	"very cute and attractive with several sensational attributes. Your femininity shines"
5	"incredibly attractive with several heart-breakingly perfect attributes"
6	"totally gorgeous with jaw-dropping beauty and hypnotic allure"
7	"flawless. It's extremely feminine; jaw-droppingly beautiful and hypnotic to stare at; men and women want nothing more than to kiss you and stare into your eyes. In fact, your face is almost otherwordly"

But it throws…

In the sentence 'Table of Beauty Descriptions level descriptor 0 "quite hideous" 1 "relatively unattractive" 2 "very plain and forgettable. Average really" 3 "attractive with a couple of cute attributes" 4 "very cute and attractive with seve [...] attributes. Your femininity shines" 5 "incredibly attractive with several heart-breakingly perfect attributes" 6 "totally gorgeous with jaw-dropping beauty and hypnotic allure" 7 "flawless. It's extremely feminine; [...] t, your face is almost otherwordly"'  , I can't find a verb that I know how to deal with.

Do I have something labeled wrong?

Anonynn.

I think you need a blank line before the beginning of a Table. (Annoyingly, I don’t think this is ever explicitly stated in the documentation.)

Ah, that worked! Weird that you have to separate them with a space though!

It’s also saying I don’t have the right punctuation but I ended it with a semi-colon and have the ‘continue this action;’ afterward…

say "Your face is [beau-descriptor] when compared to most others.[line break] Your intelligence is [int-descriptor] which could be good or bad depending on how you use it.[line break] To a complete stranger you would appear [str-descriptor] in terms of physicality. At the other end of the spectrum, you're [agl-descriptor] in regards to flexability.[line break] In any case, when you find yourself in dangerous or threatening situations, some would describe you as [for-descriptor], especially when faced with tough decisions or lust.[paragraph break] Your fame as a superhero [fame-descriptor]. With that said, the public sees you [cor-descriptor]. Whether or not this is accurate is a whole other story. It really depends on you and your actions.[line break][line break] At the moment [sle-descriptor].[line break][line break][fert-descriptor].";
continue the action;

with this error…

Problem. In the line 'say "Your face is [beau-descriptor] whe [...] eak][line break][fert-descriptor]."'  , I was expecting that 'beau-descriptor' would be something to 'say', but it didn't look like any form of 'say' that I know. So I tried to read 'beau-descriptor' as a value of some kind (because it's legal to say values), but couldn't make sense of it that way either. 

 Sometimes this happens because punctuation has gone wrong - for instance, if you've omitted a semicolon or full stop at the end of the 'say' phrase.

Man, Inform is very picky! I wish I could just write in code…

Anonynn.

Is beau-descriptor defined?

I regret to have to say that traditional programming languages are just as picky about calling undefined functions… and punctuation…

2 Likes

Yes, that particular error is the one you get when you haven’t defined a “say” phrase for the thing in the brackets. That can happen because you write “To say beau-descriptor” without the proper punctuation, but it can also happen because your “say” phrase isn’t called “beau-descriptor.”

In this case, it looks like in the above code you have “beaut-descriptor” rather than “beau-descriptor,” so I bet that’s the issue.

(One of my wishes is that the Inform compiler would detect words that only appear once and say “This only appears once, is it a typo?” That would’ve saved me some time recently when the problem was that I had written “reponses” instead of “responses,” or in the project where for reasons best known to myself I included a kind called “tchotchke” which I proceeded to misspell all over the code.)

1 Like

Oh, I know. I have a game that’s 100,000+ lines of code at the moment and over 1.8 million words xD

I guess I’m just more comfortable with typing directly as code as opposed to the way Inform 7 does it. It’s just a strange adjustment xD

Anonynn.

That solved it. I forgot the ‘t’ in [beau descriptor]

I think that’ll do it for this section! I’ll likely need some more help as the project continues. At least until I get a handle on it. Thank you so much for all your patience and thorough explanations. If I can be of help to you in the future please let me know!

Anonynn.

Possibly you would be more comfortable using Inform 6.

What’s the difference?

I was also wondering…

I would like to give the player some Character Creation choices to determine Integer Values but there are other parts that I would to be completely randomized. Like, I know how to create Tables…so would I do something like this…

decrease beauty by 1;
increase beauty by 1;

depending on the circumstances of the questions. I’m just not sure how to randomize an outcome or integer? Is it something like…

roll = GetRandomInt(1, 20)
if (roll > 15) {
}
and so on?

As good-looking as ever. <— and how do I get rid of the default “examine me” description xD?

Anonynn

let roll be a random number between 1 and 20;

Or if you just want to check the random chance and don’t need to keep the number:

If a random chance of 1 in 4 succeeds:

As for the default “x me” description, you could try

The description of the player is "description here."

or

Instead of examining the player: say "This thing."

and there are a couple of other ways.