Sorry for the strange title, it’s hard to pin down exactly what I’m requiring help for in a succint sentance. I’m using Twine 2, and the latest harlowe version (3.2.1)
For context, I’m stuck in a particularly difficult passage. In said passage, I am picking random names from an array, for the purposes of a dynamic scene with random characters. The characters are set as such:
(set:$Targets to (a: "Character 1", "Character 2", "Character 3", "Character 4")) (set:$ET1 to $Targets's (random:1,$Targets's length))
On top of this, there is a boolean variable check for whether you’ve met the character in question initially or not. I’m trying to find a more efficient way for it to check for the array’s chosen character. Because the chosen variable for the character is always random, my initial thought is to have to do an (if:) check for every available character, but I’m hoping there’s a cleaner way. It’s hard to explain, but what I have so far is the following:
(if:$ET1 is "Character 1")[ (if:$MetC1 is false)[ ] (elseif:$MetC1 is true)[ ] ] (elseif:$ET1 is "Character 2")[ (if:$MetC2 is false)[ ] (elseif:$MetC2 is true)[ ] ] (elseif...
You get the idea. Whilst this works for the purposes of what I need, I can realise from a distance that it’s messy, perhaps overdone code. I’m not a complete expert in harlowe yet so whilstI can come to solutions such as these on my own, they’re simply not efficient and can take up a lot of space in a passage that can inevitably be difficult for me to follow when editing it later.
I’ve considered datamaps but I’d be using this code in several other passages for more dynamic options. I’m just really stumped. I’ve been sifting through the documentation to find what I’m looking for but nothing is really clicking.
If anyone has done something similar in the past I’d love to hear your method. Thanks for reading!