I have an array with a list of passages, and I want to display all of them.
(set: $list to (a: "Pass1", "Pass2"))
(display: $list's 1st)
(display: $list's 2nd)
I would like a generic mechanism that can do this with any arbitrary number of values in the array.
So far I have a (live:) pseudoloop: getting a value, displaying the value, printing the value, increasing an index, printing the next value, stopping the loop when the index increases past the length of the array.
The problem with this approach is that I don't think it has a good performance. It's difficult for me to pinpoint the causes for performance problems in my game (which is way more complex than this), but this is the main mechanism and so I feel this is one of the main problems.
Can you think of any other way that I can achive this? Maybe printing all the values of the array at once and using Javascript to change the separator character?
Comments
It prints a single (display: and then the elements of the array separated by the closing parenthesis and the following (display: macro, and it ends with a single closing parenthesis.
But it works as far as I can tell and in more complicated scenarios (with the separator string having more Harlowe macros).
Sadly, the performance gains are noticeable but not that great. :-/
Thanks!
a. Add the following to your Story Javascript, it adds a new method named prefixedJoin to the Array class. b. You use the new prefixedJoin method like so: