Twine Version: Sugarcube 2.3.14
What’s a good way to count the number of boolean variables in a list that are true? I’ve tried putting the variables in an array and using
<Array>.count(true)
but that didn’t seem to work :-/
Twine Version: Sugarcube 2.3.14
What’s a good way to count the number of boolean variables in a list that are true? I’ve tried putting the variables in an array and using
<Array>.count(true)
but that didn’t seem to work :-/
Hmm, what exactly are you trying? I just ran
<<set _a to [true, false, true, true, false, false, false]>>
<<print _a.count(true)>>
and it showed 3, so it seems to work for me… Hmm. And it doesn’t look like Array.count is a new method. I’m not sure what’s going on for you
Do you have non-Boolean values in their? What does this give you (taking inspiration from Josh)?
<<set _a to [true, false, true, 1, 4, 0, "hello", null]>>
<<print _a.count(true)>>
Thanks, I fixed it - I just needed to use the print macro to show the result!
Apologies for the lack of info in the original post - I meant to include more, but it was a late-night dozy post.