code, howto, Ink

Learning Ink: Part 3: Sticky and Advanced Choices

InkLogo

 

Learning Ink

 

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


 

Sticky Choices

Introduced in the previous part as “adding back” choices, the Sticky Choice is one that uses the plus symbol “+”. Instead of being removed, it will stick around.

13_Example

In the previous extended example, this was used to loop the food choices, having all of the choices stick around each loop.

Conditional Choices

Combining diverts and knots, choices can also be conditionally shown. Because knots have unique names, code can check if they have been visited or not. When placed in curly brackets, {}, the choice will show the text or not based on the name of the knot.

1_Conditional

In the above example, the choices “Pizza?” and “Sushi?” will be shown first, as the player has not visited their knots. Once the player visits “Pizza” (making it true), the “Salad?” and “Nothing?” choices will be shown and the “Pizza?” choice will not.

Conditionals

Using Sticky Choices, Knots, and Conditional Choices, the choices will appear and disappear based on if a knot has been visited as they loop.

 

Multiple Conditionals

Conditionals checking if a knot has been visited can also be used together, checking if the player has seen (or not) a set of different knots.

2_MultipleConditionals

These can create a series of choices that have to be progressed through in order to continue, looping back and checking if other knots have been seen yet or not.

MultipleConditionals

 

Advanced Choices

Knot labels are not strictly Boolean (true or false) values. They are actually integers (numbers) and a count of how many times the player have seen the knot.

3_KnotCount

Testing if the value of the knot label is less than 1 is the same as testing if it has not been seen yet. If it has been seen multiple times, the value will be higher.

KnotCount

Testing for multiple values allows for repeating the loop between choices and knots, allowing for the same choice to be chosen and the outcome changing when repeated.

 

GitHub Git Version:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s