Tips and tricks: using strings
Welcome to our first patron-post! We'll be putting up tips and tricks here, as and when we think of them. To kick it off, here are a couple of notes about handling strings in ink.

For a text engine, ink doesn't let you do much with strings - but what's built-in might be a little surprising (especially since, um, we forgot to document it until last week.) 

The short version: Strings in ink aren't actually strings; they're ink.

The longer version: Strings ink are actually lines of ink, that are processed when the string is evaluated. That means the following:

... is perfectly sound; the dragon won't change colour from the first use of the "colour" variable to the second. 

So this is great for basic procedural text generation like the above, but it gets better, because you can nest strings inside strings.  

... and this would let you reference the breed and colouring of the creature independently, as well as having a handy go-to phrase describing the whole thing.

Remember, though, once a string has been evaluated it's sticky; so if you want the colouredCreature phrasing to shuffle itself throughout the story, it's probably best to use a function:

Lastly, once a string's been created this way, you might want ink to be able to work out what's in it. We don't provide much in the way of string handling methods (you can use external functions for those, if you need to): but we provide one, which is the "contains" operator, "has" / ?. We need it in this example because, as everyone knows, a phoenix doesn't have scales, it has feathers.

Thanks for reading and supporting ink! Happy writing.

released this post 7 days early for patrons.   Become a patron
Tier Benefits
Recent Posts