How To Write Conditionals in Adult Interactive Stories

This article will help authors of interactive adult stories use Conditionals to control readers progression through your story based on specific actions the reader has taken. For example, with Conditionals you can require a reader to find a key before they are allowed to open a specific door to a new part of your narrative. While Choices are the foundation of interactive storytelling, Conditionals are an essential element of advanced interactive world building.

Before starting on Conditionals, you should be familiar with the basics of writing interactive stories here at Literotica. Make sure you’ve read our “Getting Started With Writing Adult Interactive Stories” and “How To Write Interactive Stories With Choices” articles. Then, let’s find out more about Conditionals!

What is a Conditional?

The simplest explanation of a Conditional is that it’s an “if/then” statement - IF you have done this, THEN you can do that. IF you have a Key, THEN you can open a Door. IF you’re a Wizard, THEN you can cast a Spell. IF it’s a Full Moon, THEN you can turn into a Werewolf. IF your hit points get below 10, THEN you will pass out. These examples might remind you of video games, but they can easily be used in your Interactive Stories here on Literotica. Conditionals are simple to use once you understand the basics, but they’re powerful enough to blur the line between “Stories” and “Games”.

How Are Conditionals Used In Literotica Stories?

One of the best things about the Ink interactive fiction language is that every Knot a reader visits is recorded, so authors can use Knot names in your Conditional statements. This logic makes using Conditionals in Literotica Interactive Stories extremely simple and fast. You can check to see if the reader has visited specific Knots before you show them story text or Choices anywhere in your story, without ever having to worry about complicated Variable management.

Conditional Choices

Using Knot names as Conditionals, it’s easy to control the reader’s Choices in your story. Here’s a simple example story:


While watching TV at home, you decide you want to go out and meet a woman.
-> get_dressed

=== get_dressed ===
+ Put on jeans
-> wear_jeans
+ Put on a suit
-> wear_suit

=== wear_jeans ===
You go into your closet...
* [Go to the bar in your jeans]
and put on jeans to visit the bar.
-> arrive_at_the_bar
+ ->
and realize you're already wearing jeans.
-> get_dressed

=== wear_suit ===
You go into your closet
* [Go to the bar in your suit]
and put on a nice suit to visit the bar.
-> arrive_at_the_bar
+ ->
and realize you're already wearing your suit.
-> get_dressed

=== arrive_at_the_bar ===
You arrive outside of the bar.
+ {wear_suit} Enter the bar
The doorman compliments your suit as you enter the bar.
-> ask_a_woman_out
+ ->
This bar requires a suit to enter. You return to your house.
-> get_dressed

=== ask_a_woman_out ===
You enter the bar and have a seat. Which woman do you want to ask out on a date?
+ The blonde woman.
-> blonde_woman
+ The brunette woman.
-> brunette_woman

=== blonde_woman ===
You lived happily ever after with the blonde in New York.
-> END

=== brunette_woman ===
The brunette doesn't seem interested.
+ Try again.
-> ask_a_woman_out
+ Go home.
-> END


In this example, the reader has two possible paths to the bar:

get_dressed > wear_jeans > arrive_at_the_bar
or
get_dressed > wear_suit > arrive_at_the_bar

By simply looking at the Knot names (which you create), you can tell that what the reader is wearing when they arrive at the bar. How do we use that knowledge in a Conditional Choice? Like this:

=== arrive_at_the_bar ===
You arrive outside of the bar.
+ {wear_suit} Enter the bar
The doorman compliments your suit as you enter the bar.
-> ask_a_woman_out
+ ->
This bar requires a suit to enter. You return to your house.
-> get_dressed

This is the Choice that uses a Conditional to check whether the reader is wearing a suit:
+ {wear_suit} Enter the bar
The doorman compliments your suit as you enter the bar.
-> ask_a_woman_out

This is the Conditional:
{wear_suit}

By putting a Knot name in curly brackets “{knot_name_goes_here}” after the Choice asterisk or plus symbol, but before the text and/or Divert, you can show Choices only to readers who have visited certain Knots in your story. If you would prefer to only let people wearing jeans into the bar, you could change the Conditional Choice to this:

+ {wear_jeans} Enter the bar
The doorman compliments your jeans as you enter the bar.
-> ask_a_woman_out

Note: In the above example, we are using Fallback Choices (explained in our Choices FAQ) in the “wear_jeans”, “wear_suit” and “arrive_at_the_bar” Knots since they all have Single-Use Choices and we are potentially sending the reader to these Knots more than once.

Here is another example, this time showing a Conditional Choice checking to see if the reader has NOT visited a Knot:


It's a nice day.
-> visit_the_bank

=== visit_the_bank ===
You are at the bank.
+ Withdraw $20.
-> withdraw_money_from_bank
+ Go to the store.
-> the_store

=== withdraw_money_from_bank ===
You got $20 out of the machine.
+ Leave the bank and visit the store.
-> the_store

=== the_store ===
You arrive at the store.
+ {withdraw_money_from_bank} Buy a tennis racquet.
You buy a tennis racquet and spend the day playing tennis.
-> END
+ {not withdraw_money_from_bank} You don't have enough money to buy anything. Go back to the bank.
-> visit_the_bank


At the store, we check to see if the reader has taken money out of the bank (or not) using two Conditionals:

=== the_store ===
You arrive at the store.
+ {withdraw_money_from_bank} Buy a tennis racquet.
You buy a tennis racquet and spend the day playing tennis.
-> END
+ {not withdraw_money_from_bank} You don't have enough money to buy anything. Go back to the bank.
-> visit_the_bank

The only thing new here is that we use the “not” keyword to show the reader a Choice if they have NOT visited a specific Knot:

+ {not withdraw_money_from_bank} You don't have enough money to buy anything. Go back to the bank.
-> visit_the_bank

By using the same format as a standard Conditional, but adding the word “not” before the Knot name, we can show readers Choices only if they have NOT visited a specific Knot. In this case, we use this Conditional code “{not withdraw_money_from_bank}” to tell the reader that they don’t have enough money and they need to go back to the bank to withdraw money before they can buy anything from the store. Once they do withdraw money, we use this Conditional code to show them the tennis racquet “{withdraw_money_from_bank}”.

If we wanted to be tricky, we could require the user to visit the “withdraw_money_from_bank” Knot more than once before they could afford to buy the tennis racquet. That would look like this:

=== the_store ===
You arrive at the store.
+ {withdraw_money_from_bank > 1} Buy a tennis racquet.
You buy a tennis racquet and spend the day playing tennis.
-> END
+ {withdraw_money_from_bank < 2} You don't have enough money to buy anything. Go back to the bank.
-> visit_the_bank

In the above example, we use Conditionals Choices with greater than “>” and less than “<” symbols to show the reader they don’t have enough money to buy anything if they haven’t visited the “withdraw_money_from_bank” Knot at least two times. If they’ve visited the “withdraw_money_from_bank” twice, it means they have $40 (2 visits to the Knot at $20 each withdrawal) and they can buy the tennis racquet.

The above example offers a simple way for authors to check whether specific Knots have been visited before showing a Choice. There are more powerful ways to keep track of game inventory items (like money), but it will not be part of this tutorial. If you want to find out more about Variables, please see the “Variables and Logic” part of the Ink advanced help file.

Conditional Text

Using the same logic as Conditional Choices, you have the option to show certain text to readers only if they have (or have not) visited specific Knots in your story. Here’s a simple example:

=== the_store ===
You arrive at the store{not withdraw_money_from_bank: without any money}.
+ {withdraw_money_from_bank > 1} Buy a tennis racquet.
You buy a tennis racquet and spend the day playing tennis.
-> END
+ {withdraw_money_from_bank < 2} You don't have enough money to buy anything. Go back to the bank.
-> visit_the_bank

In the above example, if the reader has never visited the “withdraw_money_from_bank” Knot, we show them the extra text “without any money” when they enter the store. The full store entrance text reads “You arrive at the store without any money.”. If the reader has visited the “withdraw_money_from_bank” Knot, they only see “You arrive at the store.”. If you wanted to change the Knot text when the reader had enough money to buy a tennis racquet you could do the following:

You arrive at the store{not withdraw_money_from_bank: without any money}{withdraw_money_from_bank > 1: with a pocket full of money}.

We once again use the greater than “>” symbol to be sure that the reader has enough money to buy the racquet, than then show them the extra text “with a pocket full of money”. Only one text will show at a time, but there are now three texts that a reader might see when entering the store Knot:

You arrive at the store.
You arrive at the store without any money.
You arrive at the store with a pocket full of money.

Conditional Text True/False Shortcut

There’s a helpful shortcut available when using Conditional Text that allows you to show one line of text if a condition is true and a different line of text if the condition is false. It looks like this:

Example 1:
{visited_knot: You have visited the knot! | You have not visited the knot.}

Example 2:
{number_of_hours > 1: hours | hour}

The “true” text goes before the pipe symbol “|” and the “false” text goes after it. The format of this shortcut is:

{Condition: Text To Show If True | Text To Show If False}

A common way to use this shortcut is to write a singular word when the reader has one of some item, but a plural word if the reader has more than one. “Example 2” above would allow you to easily show either “It’s been one hour.” or “It’s been two hours.” depending on the value of “number_of_hours”.

Using simple Text Conditionals and Choice Conditionals to show certain story elements based on whether or not a reader has visited specific Knots opens up new ways for authors to customize their stories and create truly interactive worlds. This is just the beginning of what you can do with Conditionals in Literotica Interactive Stories. There are far more powerful logic features available that will be discussed in future advanced tutorials.

While Conditionals are powerful on their own, combining them with Variables can take your interactive story writing skills to the next level. Once you’ve mastered Conditionals, see our “Introduction to Variables For Interactive Fiction” article.

Further Reading on Advanced Conditionals

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 our own 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.