Associating a thing with a kind of number?

It’s necessary in my game to keep track of what each npc thinks of all the other npcs and the player. Currently I am doing this by using numbers.
For example, to keep track of what everyone thinks of a character called “Faceperson”, I would have this:

People have a number called facregard. Facregard is usually 3.

Or for “Mr Arsey”, I would have this:

People have a number called Arsregard. Arsregard is usually 3.

However, I haven’t figured out how to associate these kinds of numbers with the characters they are about.

Each turn, each character will do something that affects the regard of whoever they talk to (the “reactor” in the example below).
So if Mr Arsey is “the agent”, I can do something like:

				Say "[flirting of the agent][line break]";
				If reactor caresabout flirtiness:
					increase the arsregard of reactor by 1;
					Unless reactor is the player, say "[positivereaction of reactor]";
				else:
					Decrease the arsregard of reactor by 1;
					Unless reactor is the player, say "[negativereaction of reactor]";

That is specific to Mr Arsey, however. If I could replace “arsregard” in the above code with something that meant “reactor’s regard for agent”, then I could run a single piece of code and just repeat for each character, which would make everything a lot more manageable.

But Inform doesn’t let you relate things to numbers (unless there are exceptions to this I don’t know). So am I going about this the wrong way entirely?

You might want to generalize things a bit more. Here’s an alternate approach:

"opinions"

The Drawing Room is a room. 

Mr Barnett, Ms Scott, and Mrs Barnett are people in The Drawing Room.

A person has a table name called opinions. 

The opinions of Mr Barnett is the Table of Mr Barnett's Opinions. 
The opinions of Ms Scott is the Table of Ms Scott's Opinions. 
The opinions of Mrs Barnett is the Table of Mrs Barnett's Opinions. 

Table of Mr Barnett's Opinions
person	opinion
yourself	3
Ms Scott	3
Mrs Barnett	1


Table of Ms Scott's Opinions
person	opinion
yourself	3
Mr Barnett	2
Mrs Barnett	4


Table of Mrs Barnett's Opinions
person	opinion
yourself	3
Ms Scott	2
Mr Barnett	1

Every turn: 
	repeat with P running through people who are not the player:
		let O be the opinions of P;
		choose a random row in O;
		say "Regarding [person entry] [P] has an opinion of [opinion entry]. [line break]".

test me with "jump / think / x me"

Output:

[spoiler]>test me
(Testing.)

[1] jump
You jump on the spot, fruitlessly.

Regarding Ms Scott Mr Barnett has an opinion of 3.
Regarding Mr Barnett Ms Scott has an opinion of 2.
Regarding Ms Scott Mrs Barnett has an opinion of 2.

[2] think
What a good idea.

Regarding Mrs Barnett Mr Barnett has an opinion of 1.
Regarding Mrs Barnett Ms Scott has an opinion of 4.
Regarding yourself Mrs Barnett has an opinion of 3.

[3] x me
As good-looking as ever.

Regarding Ms Scott Mr Barnett has an opinion of 3.
Regarding yourself Ms Scott has an opinion of 3.
Regarding Mr Barnett Mrs Barnett has an opinion of 1.

[/spoiler]

I think George’s method could be rewritten to use a single table with three columns.

Would it be efficient to simulate the “choose a random row” line, though? That is, if we have a three column table with one column for the person whose opinion it is, one column for the person the opinion is of, and one column for the number, then we’d want to do something like “choose a random row in the Table of Everyone’s Opinions with an agent of Mr Barnett”.

But that won’t compile as such, and the ways I can think of of simulating it seem pretty inefficient. (You could repeat through the table, make a list of the row numbers that have Mr Barnett as agent, and choose one of those rows randomly; but you’d be doing that repeating and listing for every character. Or you could sort the table in agent order and choose one from a range of rows, but that requires a lot of sorting of what could be a large table.)

In general looking things up on a table by two entries at once has always seemed awkward to me, though it also has capabilities that a bunch of mini-tables wouldn’t (you could look things up by the person the opinion was of as well as the person who had the opinion).

I don’t know how likely it is that the OPer would use choose a random row though; I just threw that in there to illustrate one way to use the tables but they could always access them some other way. I like ralphmerridew’s idea of one table better, it’ll probably be easier to manage in the long run.

Thanks folks! I went with separate tables for each character. I had previously tried it with a single table, but I couldn’t figure out a syntax that worked for choosing a row based on two column criteria rather than one. I think separate tables work better for my purposes anyway.

I think you would have to repeat through the table, checking each row to see if the A entry was X and the B entry was Y. (Or, more likely, write a little “to decide” phrase to do it.)