Modifying numerical variables?

SexigeOpe

Virgin
Joined
Sep 6, 2002
Posts
37
I've learned how to assign a new value to a variable, like: "From now on variable X is 5."
But how do you add/subtract from "current value"?
Back in the 80ies when I learned BASIC it was straightforward: If "X" was an integer and I wanted to add 4, then the command was "X=X+4", meaning "(new value of) X is (old value of) X, plus 4".
Do I really need to create a temporary variable, like
(Want to add 1 to X.)
~ y = X+1
~ X = y
 
Code:
VAR x = 5          // declare x to be 5

~ x += 1          // add one to x, it is now 6
~ x += 1          // add another one, x is now 7
~ x -= 1          // subtract, x is now 6 again

{x}          // display 6 in your text

If you're using Inky, make sure the commands to add one are on their own line, with nothing else on it. No other text or diverts or anything. Inky is a bit finicky with that.
 
Last place on the web that I expected a coding question to be asked 🤣... I bet the person who asked it is a big big fan of Lit 😜 and can't think of anything other than Lit....
 
Lit's interactive stories are written in markup language Ink which allows to add all kinds of game logic and programming tricks. So this forum is the most logical place to ask about that kind of stuff.
 
I've learned how to assign a new value to a variable, like: "From now on variable X is 5."
But how do you add/subtract from "current value"?
Back in the 80ies when I learned BASIC it was straightforward: If "X" was an integer and I wanted to add 4, then the command was "X=X+4", meaning "(new value of) X is (old value of) X, plus 4".
Do I really need to create a temporary variable, like
(Want to add 1 to X.)
~ y = X+1
~ X = y
Honestly, figuring out the various ways to do variables and the options they allow narratively has been awesome. I'm also an old that learned "programing" when I was kid before the internet. Those lessons work really well in Inky!

Piece of advice. Create a separate file just for your variables. I have a file in my story called variables.ink

I set all my variables in that file and it makes it much easier to keep them all straight throughout the story.
 
This is my what is in my variable file.

// === TENSION TRACKERS ===
// Integer counters — increment with romantic/flirt choices
VAR tAmy = 0 // romantic tension with Amy
VAR tBetty = 0 // romantic tension with Betty
VAR tCharles = 0 // connection/tension with Charles
VAR tPair = 0 // Amy + Betty together
VAR tGroup = 0 // all four as a group


// === SUPERNATURAL ===
VAR exposure = 0 // 1+ = grave found; random roll fires at end of Day 2
// lenaActive triggers if roll hits (approx 10-20% overall)
VAR gTrust = 0 // trust built with Lena across possession scenes
VAR lenaActive = false // true when supernatural path has triggered


// === EVENT FLAGS ===
// Boolean — did this moment happen?
VAR ePoker = false // strip poker happened
VAR eSkinnyDip = false // skinny dipping happened
VAR eTopless = false // topless moment happened
VAR eGrave = false // Reader found the grave
VAR eNecklaceFound = false // pearl necklace recovered
VAR eHikedAmy = false // hiked with Amy
VAR eHikedBetty = false // hiked with Betty
VAR eHikedCreek = false // hiked to the creek
VAR eFootsieAmy = 0 // 1 = calf/leg, 2 = thigh, 3 = explicit
VAR eFootsieBetty = 0 // 1 = calf/leg, 2 = thigh, 3 = explicit
VAR eMorningCharles = false // spent morning alone with Charles
VAR arrivalChoice = 0 // 1 = first, 2 = together, 3 = late
VAR bedroomChoice = 0 // 1 = upstairs, 2 = downstairs
VAR eAmyBettyTalk = false // Reader and Amy had the permission conversation

// === SCENE LOOP COUNTERS ===
VAR tubLoops = 0 // resets each hot tub scene
VAR n3HotTubMoments = 0 // Night Three hot tub hub loop counter
VAR amyPositionCount = 0 // Sexual position count with Amy
VAR triangleCount = 0 // Sexual position count with triangle
VAR hotwiveCount = 0 // Sexual position count in hotwife
VAR groupCount = 0 // Sexual position count in group

// === NIGHT ONE INTIMATE SCENE ===
VAR n1Loud = false // true when Amy decides she wants to be heard
VAR n1OralAmy = false // Amy gave Reader oral
VAR n1OralReader = false // Reader gave Amy oral
VAR n1Missionary = false // missionary position
VAR n1OnTop = false // Amy on top
VAR n1Finished = false // Night One scene complete


// === NIGHT THREE PATH FLAGS ===
// Which path does Night Three take?
VAR n3Amy = false // primarily you + Amy
VAR n3Betty = false // primarily you + Betty
VAR n3Triangle = false // you + Amy + Betty
VAR n3Charles = false // Charles seed path
VAR n3Hotwife = false // you + Amy + Betty, Charles watching
VAR eAmyBettyKiss = false // Amy and Betty kissed in the hot tub
VAR n3EscAmy = false
VAR n3EscBetty = false
VAR n3EscTriangle = false
VAR n3EscGroup = false
VAR n3BackedOff = false

// === OPTION B FLAGS ===
VAR eBarricaded = false
VAR eEscaped = false
VAR eGroupFailed = false
VAR eWomenUnity = false
VAR eWomenSupportBetty = false
VAR eFailed = false
VAR eFought = false

// === OPTION A FLAGS ===
VAR aInvestBeats = 0
VAR aQABeats = 0
VAR aSearchBeats = 0
VAR aRitualEnding = ""



// === ENDING FLAGS ===
VAR endAmy = false
VAR endBetty = false
VAR endTriangle = false
VAR endHotwife = false
VAR endGroup = false
VAR endCharles = false
VAR endSupernatural = false
VAR GAMEOVER = false
 
Piece of advice. Create a separate file just for your variables. I have a file in my story called variables.ink
Good one. Although afaik the Literorica editor doesn't accept multiple files. So keep in mind that if you're looking to publish here, you need to move everything together eventually.
 
Good one. Although afaik the Literorica editor doesn't accept multiple files. So keep in mind that if you're looking to publish here, you need to move everything together eventually.
Ugh. That's really unfortunate.

When I first started this project, I had it all in one file but it became very unwieldy very fast.
 
Back
Top