Learning Ink: Part 10: Lists

InkLogo

 

Learning Ink

 

Ink is a scripting language for creating interactive fiction like choose-you-own-adventures and other vast, branching stories.


 

Lists

Along with variables and their different types like temporary and constants, Ink also has a storage type called a list. Acting like an array in other programming languages, a list allows for storing a sequence of things.

Rules for Lists:

  • Must contain unique variable names
  • Ordering matters
  • Positions start with 1 (unless overwritten)
  • Will create variables if they do not already exist
  • Created variables are set to false

Because lists will create new variables if included and not previous created, this allows for creating a list of possibilities and then having a new, separate variable with the current state.

Screenshot 2018-08-11 15.25.25

Variables using a value from the list can also be changed and used in other places.

Screenshot 2018-08-11 15.26.39

These can also be used as part of the flow once set earlier, allowing for changing states throughout a story.

Screenshot 2018-08-11 15.31.01

For dealing directly with lists, Ink also has specific functions:

  • LIST_COUNT():  The number of true entries
  • LIST_MIN() The first true entry
  • LIST_MAX(): The last true entry
  • LIST_ALL(): All entries, separated by commas
  • LIST_RANGE(list_name, min_value, max_value): A selection of the list based on its name, the starting value, and the ending value
  • LIST_VALUE(): The numerical value or, if not set, the position in the list starting at 1
  • LIST_INVERT(): Changes values to their opposites (i.e. changes Booleans from true to false)

Ink also has the ability to test for inclusion:

  • ?: If multiple entries are part of the list and true
  • has: If an entry is part of the list and is true
  • hasnt: If an entry is not part of a list and not true
  • !?: If multiple entries are not part of the list and not true

GitHub Gist Version: