This post is about a little about lists. Lists in ink are (a) very odd, and (b) a big topic with lots of ins and outs, but here's a couple of important first ideas, and some useful functions.
First up, we're really sorry about the name. These lists are not like lists in C#. They aren't arrays. (They're more like a hashset of enums.) We tried calling them sets but "set" is one of the wooliest words in the English language, so we plumped for "list", which is probably the second wooliest.
A list is: a set (darn) of on/off states, that's always ordered the way you set it up to be. Things can be in the list, or out of it, but that's all.
More confusingly, a variable list can contain elements from lots of different lists, and they'll still be sorted.
Ink provides a bunch of ways to handle lists - you can access the full set of states (LIST_ALL), the inverse of the current "on" set (LIST_INVERT), the maximum and minimum "on" values in the current list (LIST_MIN, LIST_MAX).
We can also get the n-th element in a list, if we build a function to do that recursively...
... and best of all perhaps, that lets us choose a random element:
This idea, of recursively chomping through lists, is incredible powerful. For instance, here's a way of selecting our favourite fruit from a fruit-bowl, using a scoring function.
Thanks for supporting ink, and happy writing!
Pledge $0 or more per month
Pledge $0.01 or more per month
This level is recommended for hobbyists and dabblers.
This level is recommended for independent creators.
Corporate generosity, because that's a thing
This level is recommended for successful studios using ink as part of your pipeline.