Using Choice Labels In Interactive Story Conditional Statements

In this article we’ll cover Labels, which can be added to Choices to improve tracking of a reader’s path through your narrative. To get the most out of this tutorial, you should be familiar with writing Choices, Conditionals, and Variables.

What Are Labels in Literotica Interactive Stories?

Labels are names you can add to a Choice so you can track how many times a reader has visited that Choice throughout the story. One of the foundations of the language used to write Literotica Interactive Stories is that Knot names are defacto Variables. Labels are another type of defacto Variable. Here is a basic example of a Choice Label in use:

=== knot_1
You feel a little tired.
+ (hours_of_sleep) Sleep for 1 hour.
-> knot_1
+ Continue the story.
-> knot_2

=== knot_2
You slept for {knot_1.hours_of_sleep} hours!
-> END

The Label in this example is “hours_of_sleep”. Labels are added to Choices inside of parenthesis, after the Choice symbol but before the text:

+ (hours_of_sleep) Sleep for 1 hour.

A Label name must use the same format as a Knot name - spaces are replaced by underscore characters.

Once you add a Label to a Choice, you can find out how many times the reader has clicked the Labeled Choice by using the dot format “knot_name.choice_name”. The Knot name and the Choice name are connected by a period/dot symbol in a type of breadcrumb, with the largest container (Knot Name) first, and the smaller container (Choice Label) next. This is a standard way to access Variables in some programming languages. Here’s how it looks in our example:

{knot_1.hours_of_sleep}

If you try to access the Label using only “hours_of_sleep” it won’t work because the script needs to understand in which Knot the Choice Label is contained. The exception to this rule is you can access the Choice Label without the Knot name inside of the same Knot where you create the label:

=== knot_1
You feel a little tired. You've slept for {hours_of_sleep} {hours|{hours_of_sleep > 1: hours | hour}}.
+ (hours_of_sleep) Sleep for 1 hour.
-> knot_1

In programming terms, the Choice Label can be accessed locally (inside of its own Knot) without a parent name (Knot name), but to access it globally (in any Knot other than the one where it was created), you must use the dot format with the parent (Knot name) before the Choice Label.

Here is a more advanced example:

Start the story here.
-> knot_1

=== knot_1
You feel a little tired.
+ (hours_of_sleep) Sleep for 1 hour.
-> knot_1
+ Continue the story.
-> knot_2

=== knot_2
You feel a little tired.
+ (hours_of_sleep) Sleep for 1 hour.
-> knot_2
+ Continue the story.
-> knot_3

=== knot_3
You feel a little tired. You've slept for {hours_of_sleep} {hours|{hours_of_sleep > 1: hours | hour}}.
+ (hours_of_sleep) Sleep for 1 hour.
-> knot_3
+ Continue the story.
-> knot_4

=== knot_4
You slept for {knot_1.hours_of_sleep} {knot_1.hours_of_sleep > 1: hours | hour} in Knot 1!
You slept for {knot_2.hours_of_sleep} {knot_2.hours_of_sleep > 1: hours | hour} in Knot 2!
You slept for {knot_3.hours_of_sleep} {knot_3.hours_of_sleep > 1: hours | hour} in Knot 3! -> END

Note: You may want to copy the above code into an Inky window to test it yourself.

In the example above, we created several different Knots with the exact same Choice Label “hours_of_sleep” in each. In knot_4 we access each of the labels using the dot format and the name of each Knot:

knot_1.hours_of_sleep
knot_2.hours_of_sleep
knot_3.hours_of_sleep

In knot_3 we also use the local Label “hours_of_sleep” without the dot format since it’s being accessed inside of the same Knot where it was created (a “local” Variable). It’s important that you understand how to access Labels inside and outside of the Knot where they were created to avoid any confusion when Label names may be similar or identical.

Using A Choice Label In A Real Story Scenario

What might we use Choice Labels for in an actual Interactive Story published on Literotica?

A Choice Label is a defacto Variable that is always equal to a number. The value of a Choice Label is the number of times that the reader has clicked on that Choice in your story. We can use Choice Labels as either true/false (0=false, greater than zero=true) or a real number.

Here’s an example of a story that uses a Choice Label to only allow the reader to find a hidden door after they’ve tried walking down the same hallway more than four times:

The story starts here.

-> visit_a_rural_house

=== visit_a_rural_house
{You arrive at the rural house.|} You're {|still} not sure why you came here. Standing in the kitchen {|again}, you wonder what to do next.

+ (hallway) Walk down the long hallway.
-> long_hallway
+ Enter the living room.
-> living_room

=== long_hallway
You walk down the hallway{| for a second time| for a third time| for a fourth time|}. It seems to go nowhere{visit_a_rural_house.hallway > 4:, but {as your eyes adjust to the darkness, you think|} you see the outline of a secret door on the wall}.
+ {visit_a_rural_house.hallway > 4} Try to enter the secret door.
-> secret_door
+ Go back to the kitchen.
->visit_a_rural_house

=== living_room
You enter the living room. Nothing much to see here.
+ Go back to the kitchen.
->visit_a_rural_house

=== secret_door
You find the entrance...to a new way to write stories!
-> END

In this story, no matter how many times the reader visits living room, nothing will happen. However, we use the Choice Label “hallway” to keep track of how many times the reader goes down the long hallway.

Nothing happens the first four times they go down the hallway (except for minor text variations using Sequential Lists). The fifth time they walk down the hallway, they’re able to see the outline of a secret door:

It seems to go nowhere{visit_a_rural_house.hallway > 4:, but {as your eyes adjust to the darkness, you think|} you see the outline of a secret door on the wall}.

We use a Conditional Choice with the Choice Label “visit_a_rural_house.hallway” to allow them to enter the door on any visit after their fourth visit:

+ {visit_a_rural_house.hallway > 4} Try to enter the secret door.
-> secret_door

As we’ve discussed in previous articles, once the reader reaches the “secret_door” Knot, we can check the Knot name anytime in the story to confirm that the reader has entered the secret door. But Choice Labels give us an additional - even more targeted - way to keep track of what readers are doing in our stories.

If you think of Choice Labels as Local Variables that do not have to be declared, and that can be accessed anywhere in your story by using dot format, you’re likely to find lots of uses for them in your writing.

Further Reading on Choice Labels

The creators of the Ink language have written a detailed help document explaining how to use every advanced feature of the language. If you’re interested in becoming a power user, please see their “Writing With Ink” tutorial for more information. We also have a growing library of Interactive Story Writing Tutorials and FAQs that you might want to read.

If you’re interested in helping test and give feedback on the new Literotica Interactive Story format, either as an author or a reader, please read this thread in the Literotica Forum: Interactive Adult Story Testers Needed.