The Array documentation explains you can use brackets ( ) to evaluate an expression to determine the array index/position to use, and a (story or temporary) variable ca be used as an expression.
(set: $array to (a: "one", "two", "three"))
(set: _index to 2)
2nd element of array: (print: $array's (_index))
... and you can use this technique with a datamap.
(set: $map to (dm: "first", "abc", "second", "def", "third", "hij"))
(set: _key to "second")
value of map key "second": (print: $map's (_key))
... and now that you know that the only issue left is how to access the character related story variables.
The simplest solution to that is to replace your character related story variables with a datamap that contains each of those variables as keys/value pairs.
(set: $party to (dm:
"Char1", (dm: "Name", "value", "Race", "value1"),
"Char2", (dm: "Name", "value", "Race", "value2"),
"Char3", (dm: "Name", "value", "Race", "value3")
))
(set: _char to "Char2", _attr to "Race")
2nd character's race: (print: $party's (_char)'s (_attr))
If you still want to keep the individual character related story variables then you could use a slight variation on the above solution by temporary creating the party variable within the passage you want to display the values in.
(set: _party to (dm:
"Char1", $Char1,
"Char2", $Char2,
"Char3", $Char3
))
(set: _char to "Char2", _attr to "Race")
2nd character's race: (print: _party's (_char)'s (_attr))