Hello,
I require some advice on how to rationalise a section of my Harlow coding. I'm sure it can be done better.
Reading a lot of Le Carré novels, I wanted to put together a retro spy story. In it I have an event, where the player gets followed. I want the player to spot a few clues about the person following them, and piece the information together themselves later. I've one passage, which contains the various spy descriptions, and another that contains the event.
"spies"
{
<!-- SPIES -->
(set: $alfred to (dm:
"active", false,
"age", 25,
"name", "Alfred Grey",
"nation", "Britain",
"attspot", "null",
"attributes", (ds:
"brown hair",
"tall",
"moustache"
)
))
(set: $chuck to (dm:
"active", false,
"age", 30,
"name", "Chuck Dawson",
"nation", "USA",
"attspot", "null",
"attributes", (ds:
"blonde hair",
"average",
"beard"
)
))
(set: $robin to (dm:
"active", false,
"age", 42,
"name", "Robin Lindmaa",
"nation", "Estonia",
"attspot", "null",
"attributes", (ds:
"red hair",
"short",
"clean shaven"
)
))
(set: $rene to (dm:
"active", false,
"age", 33,
"name", "René Marchand",
"nation", "France",
"attspot", "null",
"attributes", (ds:
"brown hair",
"average",
"clean shaven"
)
))
(set: $ermolai to (dm:
"active", false,
"age", 27,
"name", "Ermolai Kirov",
"nation", "USSR",
"attspot", "null",
"attributes", (ds:
"blonde hair",
"tall",
"moustache"
)
))
(set: $narek to (dm:
"active", false,
"age", 48,
"name", "Narek Petrossian",
"nation", "Armenia",
"attspot", "null",
"attributes", (ds:
"red hair",
"short",
"beard"
)
))
<!-- SPY LIST -->
(set: $spy to (ds:
$alfred,
$chuck,
$robin,
$rene,
$ermolai,
$narek
))
}
"event"
{
<!-- SPY SELECT -->
(set: $npc to (either:
...$spy
))
<!-- SPOTTED SPY ATTRIBUTE -->
(set: $npc's attspot to (either:
...$npc's attributes
))
<!-- ATTRIBUTE DESCRIPTION/SUSPECT -->
(if: $npc's attspot is "brown hair")[
(set: $npcdesc to "They have brown hair.")
(set: $suspect1 to $alfred, $suspect2 to $rene)
]
(else-if: $npc's attspot is "tall")[
(set: $npcdesc to "They are tall.")
(set: $suspect1 to $alfred, $suspect2 to $ermolai)
]
(else-if: $npc's attspot is "moustache.")[
(set: $npcdesc to "They have a moustache.")
(set: $suspect1 to $alfred, $suspect2 to $ermolai)
]
(else-if: $npc's attspot is "blonde hair")[
(set: $npcdesc to "They have blonde hair.")
(set: $suspect1 to $chuck, $suspect2 to $ermolai)
]
(else-if: $npc's attspot is "average")[
(set: $npcdesc to "They are average in height.")
(set: $suspect1 to $chuck, $suspect2 to $rene)
]
(else-if: $npc's attspot is "beard")[
(set: $npcdesc to "They have a beard.")
(set: $suspect1 to $chuck, $suspect2 to $narek)
]
(else-if: $npc's attspot is "red hair")[
(set: $npcdesc to "They have red hair.")
(set: $suspect1 to $robin, $suspect2 to $narek)
]
(else-if: $npc's attspot is "short")[
(set: $npcdesc to "They are short in height.")
(set: $suspect1 to $robin, $suspect2 to $narek)
]
(else-if: $npc's attspot is "clean shaven")[
(set: $npcdesc to "They are clean shaven.")
(set: $suspect1 to $robin, $suspect2 to $rene)
]
}
In the window of an antiquated bookshop, you see a stranger following you.
(print: $npcdesc)
Remembering the dossier, you have some suspects in mind:
1. (print: $suspect1's name)
2. (print: $suspect2's name)
The event works well, but the 'Attribute description/suspect' part is unwieldy. I was thinking of using Lamdas, but I'm struggling getting my loaf around them. I've already managed to nest datasets containing attributes, inside each spy's datamaps; maybe this is the way forward.
I also hoping there was a way I could connect up the suspect identifier, to the attribute, so I wouldn't have to set them for each one, and they'd be called automatically.
Any help would be greatly appreciated.