Code Example Simple Character Creation

Code:
//Introduction goes here
+[Lets get started.]
-> Start


=== Start ===
VAR Name = ""
What is the main character's name?

+ [Taylor]
~ Name = "Taylor"
->Ethnicity

+ [Madison]
~ Name = "Madison"
->Ethnicity


== Ethnicity ==
VAR Race = ""

What race is she?

+ [White]
~ Race = "white"
-> Hair

+ [Asian]
~ Race = "asian"
-> Hair


== Hair ==
VAR HairDescription = ""

What hair color does she have?

+ [Blonde]
~ HairDescription = "blonde"
-> Tits

+ [Red Head]
~ HairDescription = "red headed"
-> Tits


== Tits ==
VAR Breastsize = ""

How large are her breasts?

+ [Average]
~ Breastsize = "average"
-> ACT1

+ [Large]
~ Breastsize = "large"
-> ACT1


=== ACT1 ===

It was {Name} Evans's 19th birthday and her feet hurt.

A long day of school and a grueling practice had left the lithe teenager exhausted. The {HairDescription}, {Race} cheerleader had finished practice to find that her stepbrothers hadn’t shown up to pick her up from school. Not that she really wanted their company, they always leered at her {Breastsize} breasts whenever her mother wasn't around.
->END

//If you did it all correct, the reader should see this after making their choices:

It was Taylor Evans's 19th birthday and her feet hurt.

A long day of school and a grueling practice had left the lithe teenager exhausted. The red headed; white cheerleader had finished practice to find that her stepbrothers hadn’t shown up to pick her up from school. Not that she really wanted their company, they always leered at her large breasts whenever her mother wasn't around.


//Ink will also track choices made and we can use (labels) to insert additional conditional text based on those choices. Let’s modify our [Red Head] choice and show that.

+ (RedHead) [Red Head]
~ HairDescription = "red headed"
-> Tits

It was {Name} Evans's 19th birthday and her feet hurt.

A long day of school and a grueling practice had left the lithe teenager exhausted. The {HairDescription}, {Race} cheerleader had finished practice to find that her stepbrothers hadn’t shown up to pick her up from school. Not that she really wanted their company, they always leered at her {Breastsize} breasts whenever her mother wasn't around.

{Hair.RedHead: She sighed and started to walk home. Like all red heads, she had fair skin that was sure to burn in the baking sun.}

->END

//If you did it all correct, ink will show the additional text only if the choice [Red head] was chosen:

It was Taylor Evans's 19th birthday and her feet hurt.

A long day of school and a grueling practice had left the lithe teenager exhausted. The red headed; white cheerleader had finished practice to find that her stepbrothers hadn’t shown up to pick her up from school. Not that she really wanted their company, they always leered at her large breasts whenever her mother wasn't around.

She sighed and started to walk home. Like all red heads, she had fair skin that was sure to burn in the baking sun.

Notes:

  • This is simple character creation using ink code.
  • I’m operating under the assumption that Literotica will be running on vanilla ink code at launch and won’t already have a system in place for this.
  • We will be using: Global Variables, Conditional text, Labels and Choices in this code example.
  • Let’s break the first part of code down step by step. We’re going to set up a Global Variable called Name. A Global Variable is simply a variable that can be assessed anywhere in the story, it is delineated with a VAR statement, followed by the name of the variable and then an equal sign. This code will be invisible to the reader and is used by ink in the background.
VAR Name = ""


//We will then ask the reader a question. This will be visible to the reader.

What is the main character's name?


//First line after the question is a choice that the reader will see. This is clickable like a hyperlink in the story.

+ [Taylor]


// When the choice Taylor is clicked on it will activate the second line. The second line is a line of code that will set the Global Variable Name to whatever is within the parenthesis. So Name is now set to Taylor.

~ Name = "Taylor"




//Third line is a simple Divert that will move the reader out of the current knot and into the next knot, moving the story along.

->Ethnicity


Now that the reader has chosen Taylor as the main character’s name, when we type {Name} into the editor, the name Taylor will appear to the reader.

  • Ink can also do more than simply give the reader a choice and insert a character name into the story. At some point we may want to use that choice to add conditional text. Conditional text is text that will only be visible if a certain choice has been made or a particular knot has been visited. We will track choices by inserting a Label. That looks like this:

+ (label) Choice

In our example we added the label (Redhead) to the original choice of + [Red head]

+ (RedHead) [Red Head]


We can then use that label to insert text into the story, if and only if the choice [Red head] was chosen. That looks like this:

{knot.label: text}

This is a logic test that ink is performing in the background. It’s read like this: If knot was visited and label was chosen then display text.

In our editor that looks like this:

{Hair.RedHead: She sighed and started to walk home. Like all red heads, she had fair skin that was sure to burn in the baking sun.}

If the [Red Head] choice was chosen then this text will appear, other wise it will remain invisible to the reader.

She sighed and started to walk home. Like all red heads, she had fair skin that was sure to burn in the baking sun.
 
Last edited:
Hey, this is very helpful.

Die Ink have objects? I’d like to be able to, for example, iterate over a set of objects representing characters or locations, or to store undivided data about a set of characters. Is that feasible?
 
Hey, thanks for putting this up!

I am brand new at this type of writing, so going with the very basics for my first try.
Having variables makes a huge difference in what would otherwise have to be a bunch of separate branches.

One thing I picked up on while doing this myself is that you can add more than one variable to a selection.

Using the original example:

VAR Name = ""
What is the main character's name?

+ [Taylor]
~ Name = "Taylor"
->Ethnicity

+ [Madison]
~ Name = "Madison"
->Ethnicity

Can be turned into this:

VAR Name = ""
VAR Nick = ""
What is the main character's name?

+ [Taylor]
~ Name = "Taylor"
~ Nick = "Tay"
->Ethnicity

+ [Madison]
~ Name = "Madison"
~ Nick = "Maddy"
->Ethnicity

Notice that now you have chosen a nickname that can be inserted as well as the basic name.
so a friend of the character can say
"Hi, {Nick}!"
and the appropriate nickname will be there.

I used this for gendering a player-based character.
using:
VAR SEX = ""
VAR PRO = ""
VAR sPro = ""
VAR aPro = ""
VAR pPro = ""
VAR SEXnom = ""
VAR SEXinf = ""

with the two options

+ [male]
~ SEX = "man"
~ PRO = "He"
~ sPro = "he"
~ aPro = "him"
~ pPro = "his"
~ SEXnom = "sir"
~ SEXinf = "mister"

or

+ [female]
~ SEX = "woman"
~ PRO = "She"
~ sPro = "she"
~ aPro = "her"
~ pPro = "hers"
~ SEXnom = "ma'am"
~ SEXinf = "lady"

I imagine there's a more advanced way to do it somehow, but keeping it simple and using variables was very handy for me.
Hope this helps and thanks again for the original post. It's a challenge so far but I like it.
 
Back
Top