Indirectly referencing a table by a variable name ...

Bear with me for my poor explanation … what I intend to do is the following:

Certain people can wear certain things.
The player randomly assumes the role of one of these people. (Not by “now the player is” as this causes TONS of problems)
People are assigned roles so that I cloth them much later
Now - the player is supposed to wear what the person would normally wear if not in a special role
I have a table for that
Now … instead of doing an endless loop over all possible characters and see who I am and which table to look for I want a better solution :slight_smile:

Like so:

MyRoom is a room.

when play begins:
	Let R be the firstname of the player;
	Let R be "[R] Clothes";
	Say "Debug: [R]";
	let L be the list of items in the table of R; 
	Say "Done!".
	
a person has a text called firstname.
The firstname of the player is "Kerstin".

the sweater is wearable.
the jeans is a wearable.
the Bluse is a wearable.
The rock is a wearable.

Table of Olga Clothes
item	description
sweater              " "
Jeans                 " "

Table of Kerstin  Clothes
item	description
Bluse	" "
Rock	" "

This does not work because R is a text and the interpreter extects a proper Table (as object) - is there a way to “convert” the text R so that what I am intending to do would work?

Because if it would work, all I had to do is loop through the item column of the proper table and wear the items.

I doubt whether that is possible. (Maybe there is an Inform 6 method.)

What is possible in I7 is to retrieve the text “Kerstin” from the Table of Kerstin Clothes. So instead of having the firstnames in your indexing table, you could have the corresponding table names, and then use that to work out the player’s firstname.

A person has a table name called the personality index.
The personality index of the player is the Table of Kerstin Clothes.

To decide what text is the firstname of (X - a person):
     let T be the personality index of X;
     decide on word number three in the substituted form of "[T]".

I’m not at all sure this is a good solution to your problem though. I would just put more information into an indexing table. More typing, but much more convenient to work with.

Table of Identities
name       clothes list                [other stuff]
"Kerstin"   Table of Kerstin Clothes      ...
"Magda"     Table of Magda Clothes        ...

And now it’s easy to choose a random row when play begins, and all the information you need is ready to hand.