Ultimate Noob Coding


Everywhere seems relatively easy, it’s not hard to copy and paste afterall XD


Unless you later decide to make it based on five relationships or something. I’d recommend using *gosub_scene if you’re going to be using a gosub anyways. They basically exist for exactly that reason.


If you use morale stat, say, 2 times in a scene, but relationship stats change 20 times, you can do that:
in choicescript_stats:

*set Morale round(((Brett + Linda) + (Herby + Samirah)) /4)
    percent Morale

and then only set Morale right before using it in the scene.
For example:

*set Morale round(((Brett + Linda) + (Herby + Samirah)) /4)
What is your loyal squad doing?
*if Morale < 50
    They've just went smoking without you.
*if Morale >= 50
    They are fighting for your cause till their last breath.

That way, a player will see the average value of 4 relationship every time they look at the stats, but you don’t need to set Morale 20 times.


will this even work:

   You nod.
   *page_break ...
   *page_break ...
   *page_break ...
   And let out a bloodcurdling scream, flail, and jump when the realization sinks in.

as in, will the game display an empty page proper or give an error or something?


Tried to test it, there is no empty page, the program treats 3 *page_break commands like one.


ah, damn… thanks
mhnn… replacing the second one with just … should work


I’m working on my first story and wondered about a couple things.

  1. Is it possible to trigger scenes, choices, dialogue, etc. with previous choices? For example, if you kill X, then casually talk to detective Y later down the line, the previous choice to kill X will trigger detective Y to be suspicious and unlocking a series of questions/dialogue that otherwise would not unlock.

  2. If choices x, y, and z lead to point A, but with different dialogue, different descriptive words, etc. is it best to just code them separately or is there an easier way to achieve that without compromising the minor differences?

If you know of any examples, please let me know! It’s a vast world of CS out there :dizzy_face:


Both of these are solved using variables and *if statements; you’d set variables on an earlier choice then check them later.

  1. Make separate labels for the two versions and one label for when they meet back up. At the branch, use something like so
*if suspicious
    *goto suspected
    *goto trusted

Then at the end of both do

*goto meetingover
  1. The answer varies, but if you’re just changing bits of text in a page you’re better off putting text variables or if statements in a single scene. Usually text variables are good for short things you’ll use a lot like names and if statements are good for whole sentences you don’t use much


Thanks! I couldn’t figure out how I could use variables and if/else, but you made me look at it from a different point of view. Thanks again!


Thaannk youuuu so muuch :sob::sob: you have no idea… how much that dumb endless text feature annoyed me. :pray::raised_hands::clap::clap::grin:


Yeah, that was the first of many, many, many errors that really drove me nuts. Glad I wasn’t the only one!


If they really are minor differences, then multireplace is great.

Like, if your base exchange is:

Y opens the door for you as your approach the cafe. "Fancy seeing you here," he says.

You gesture to the menu. "I'm addicted to their maple latte."

"Come here daily then?" Y asks, slipping in line behind you.

"Seems like it."

"I'll have to try that latte then. Can't pass on an expert opinion."

Then you could write that using multireplace to make Y more suspicious.

Y opens the door for you as your approach the cafe@{susp , brows raised.|.} "Fancy seeing you here," he says. @{susp His voice scrapes down your back like fingernails on a chalkboard. It is uncannily casual.|}

You gesture to the menu. "I'm addicted to their maple latte." @{susp Neither your hand nor voice shakes.|}

"Come here daily then?" Y asks, slipping @{susp between you and the door.|in line behind you.}

"Seems like it." 

@{susp He hums as though your answer has revealed something. You resist the urge to demand he explain.|"I'll have to try that latte then. Can't pass on an expert opinion."}

What’s fun is that you can then write the same bit taking multiple world states in consideration. For example, Y being suspicious is one. But maybe earlier you asked the MC for their favorite latte flavor. Or maybe, the MC owns the cafe or not.

*comment cafe_own: 1 is MC owns it; 2 is someone else own it.
Y opens the door for you as your approach @{cafe_own your|the} cafe@{susp , brows raised.|.} "Fancy seeing you here," he says. @{susp His voice scrapes down your back like fingernails on a chalkboard. It is uncannily casual.|}

@{cafe_own "I thought the owner should make an appearance at some point."|"Oh, hello," you say, stepping inside.} You gesture to the menu. "I'm addicted to @{cafe_own our|their} @{latte_fav maple|vanilla|mint|caramel|mocha|chai} latte." @{susp Neither your hand nor voice shakes.|}

"Come here daily then?" Y asks, slipping @{susp between you and the door.|in line behind you.}

@{cafe_own "It's a living."|"Seems like it."} 

@{susp He hums as though your answer has revealed something. You resist the urge to demand he explain.|"I'll have to try that latte then. Can't pass on an expert opinion."}

…basically, I adore multireplace.


I really wish I understood multireplace. I am sure it would be helpful, but I think my eyes glazed over while reading your post on it. It’s just a bit too in the weeds for me to grasp yet, I suppose.

Okay guys, I’ve done fairly well on my own for a bit but now I’ve encountered a sticky sort of widget. I am introducing a money variable to my WIP. That’s not too hard in and of itself. The issue is I want to find some way to make the amount of money display with the proper dollar signs and commas (no decimal points, we’re not going that far down), while still having it as an actual variable for the purpose of stat checks and things. Doable? Or a pipe dream?


It might be helpful to make a separate “game” just for testing code fragments. I know I only started to get a grasp on multireplace after I started practicing with it in a Code Test file. Reading the descriptions and explanations did nothing for me.

This alone is easy enough. For the game itself, simply type the currency symbol, then type your “display a variable here” statement right beside it. If you want the currency symbol in front: $${money}. And if you want the currency symbol in back: ${money}$. Obviously, the location of the currency symbol is culture-specific.

For a stat chart, maybe make a *temp variable containing the above as its value, then display the temp. Like so:

*temp cash "$${money}"
    text cash Money

This is where things start to get a little trickier. Even setting aside that the comma notation is not universal across cultures; this part is just mechanically more trouble.

Honestly, I’d probably use a second variable and a subroutine to make a right proper mess of it.

It might end up like this if I did it...

Okay, so. I got this working, at least in my test file. I’m not actually sure I can explain what I’ve done, beyond admitting to abusing concatenation and ChoiceScript’s ability to extract a specific character from a variable’s contents

First, these are the permanent variables I’m using in this example. I chose “bucks” and “cash” because reasons (don’t ask). One is intended for behind-the-scenes use: The actual buying and selling; or earning and losing. That’s bucks, and it’s just a plain numeric variable. The other (cash) is for display, so it’s a string variable.

*create bucks 0
*create cash " "

Second, I put my subroutine in a file named subroutines.txt, so I called it this way:

*gosub_scene subroutines bucks_to_cash

And here’s the disaster itself. It’s a real nightmare… but it’s working at least?

*label bucks_to_cash

*temp bucks_digits length(bucks)

*if bucks_digits <= 3
    *set cash "$${bucks}"

*if bucks_digits > 3
    *set cash (bucks#(bucks_digits -3)) & ","
    *set cash (cash & (bucks#(bucks_digits -2)))
    *set cash (cash & (bucks#(bucks_digits -1)))
    *set cash (cash & (bucks#(bucks_digits)))

*if bucks_digits > 4
    *set cash ((bucks#(bucks_digits -4)) & cash)
*if bucks_digits > 5
    *set cash ((bucks#(bucks_digits -5)) & cash)
*if bucks_digits > 6
    *set cash (((bucks#(bucks_digits -6)) & ",") & cash)
*if bucks_digits > 7
    *set cash ((bucks#(bucks_digits -7)) & cash)
*if bucks_digits > 8
    *set cash ((bucks#(bucks_digits -8)) & cash)
*if bucks_digits > 9
    *set cash (((bucks#(bucks_digits -9)) & ",") & cash)
*if bucks_digits > 10
    *set cash ((bucks#(bucks_digits -10)) & cash)
*set cash "$${cash}"

Note, this is only useful up through eleven-digit numbers. If you ever allow your players to break $99,999,999,999 you’ll have to add extra lines to the code to account for any extra digits.

So, what’s actually happening in that mess? uhh…

Well, it starts with creating a temp variable bucks_digits to measure how many digits long the value of the variable bucks is. The length check is actually pretty simple. It’s just length(variable_name). Since the variable we’re measuring is bucks, that works out to length(bucks), the result of which is stored as bucks_digits (our temp variable).

Next, we find out if bucks is three digits or less by checking the value of bucks_digits. If it’s three or less, we add the dollar sign and store it in the cash variable for display. That’s easy enough. That indented section gets its own *return command not because it’s necessary, or even helpful, but because I could get away with it.

However, if it’s more than three digits, we need to start adding commas.

Here’s why I’m making such a mess of what comes next: I don’t actually know any way to insert characters into the middle of an existing variable. So I’m grabbing the digit before the comma (bucks#(bucks_digits -3)) and concatenating it with a comma & ",". Then I’m taking that output, and adding the three values that follow the comma, one at a time, from closest to the comma to furthest from the comma.

From there, if I need more digits, I’m concatenating them onto the front.

The last line before the return adds the readable dollar sign. I didn’t bother with concatenation for this line, as there was no advantage. Just $${cash} is good enough.

Edit: To make sure bucks and cash are always representing the same number, it’s probably wise to run the subroutine every single time the players’ actual money value changes.

I’m about 99% convinced this explanation is nowhere near sufficient, and I’m genuinely sorry. Unfortunately, it’s the best I can do at the moment.


Ah, that looks like an elegant solution for the dollar sign, at least (it’ll be in the front. I love my international readers, but this is 'Murrrrica, and in 'Murrrrica the dollar tends to come before everything!), and I can always let the comma slide. Thanks!


I’m gonna teach that to my students. They’re always frustrated by that.


Hm… maybe this story will help?

The Delle Triplets are the most feared food critics in the whole city. When a restaurant learns one of the triplets will be visiting, they brainstorm how best to impress her. They decide that a good first impression is most important, so they will have the triplet’s drink ready for her at her table. The only problem is–they don’t know which triplet will be visiting and each triplet has a different favorite. Amber likes tea, Beatrice prefers a strong, dark beer, and Claire will only drink a diet soda with lemon. Only once the triplet enters will the restaurant know. So they decide on a code. Once the hostess knows which triplet has come, she’ll flash 1, 2, or 3 fingers to a lurking waiter who will then rush to get the right drink on the table. 1 for Amber, 2 for Beatrice, and 3 for Claire.

When the triplet arrives, the hostess realizes it is Beatrice. She flashes a “2” to the lurking waiter. When she reaches the table, the strong, dark beer is waiting.

In multireplace, that last line would look something like:

(Note: earlier code would basically say "If the triplet who arrives is Beatrice, set ‘triplet’ to 2).

When she reaches the table, the @{triplet tea|strong, dark beer|diet coke with lemon} is waiting.

Alternate story:

A husband wants to impress his wife’s coworkers by telling them “hello” in their own language during a party. Her co-workers speak English, German, French, and Japanese. His wife promises to hold his arm or hand and will squeeze 1, 2, 3, or 4 times whenever they approach someone new so that no one sees her tell him which language to use. 1 for English, 2 for German, 3 for French, and 4 for Japanese. That night, as his wife guides him toward one of her coworkers, she squeezes his arm twice to signal the coworker’s native language is German.

“Honey,” she says, “This is Karl.”

“Guten Abend,” the husband replies.

In multireplace that last line would be:

(Note: the wife squeezing his arm twice set ‘coworker_language’ to 2)

“@{coworker_language Good Evening|Guten Abend|Bonsoir|Konbanwa}”, the husband replies.

…does that help at all?


I feel like I’m almost there. So we’re saying that if variable = 3, it will automatically display the third thing in that set of options split by the lines inside the bracket? Bonsoir, to use the second example?


Exactly! @liszante has done a much better explaining this than I could.

Trying to extend from those examples, you use also multireplace with a Boolean variable; and as a simple *if check. When doing that, the “true” or “pass” results are treated as a numeric 1, using the exact same process as above. The “false” or “fail” results are treated as a numeric 2. So:

@{(fuel > 12) You have adequate fuel.|You need to declare a fuel emergency.}

This is essentially *if (fuel > 12) where passing the check allows you to continue flying your plane, while failing the check requires you prepare to immediately land (hopefully at the airport).

@{has_hat Your hat protects your hair from the rain.|The rain soaks your unprotected hair.}

This is essentially *if (has_hat) where a true value for the Boolean keeps the rain off, while a false value lets the rain hit you.

Hopefully I haven’t confused the issue too badly. All this is, in effect, extra.

Edit: On further contemplation, I believe the parentheses are only required when using multireplace as a *if, and are unnecessary when using it with a Boolean.


I find I get an error when I set it out the first way mentioned there because Quicktest doesn’t know what to do it the variable is 0 (even if that’s not possible). So I would write it like this:

Beatrice walks in.
*set triplet 2

When she reaches the table, the @{triplet+1 |tea|dark beer|diet soda with lemon} is waiting.

Basically, it separates the possible outcomes with the | symbol. It checks the value of triplet. If it’s 0, it outputs nothing. If it’s 1, it outputs tea. If it’s 2, it outputs dark beer. If it’s 3, it outputs diet soda with lemon. (if it’s 4 you’ll get an error because there aren’t enough options in the multireplace for that)

Since the second triplet Beatrice comes in and the triplet variable is set to 2, it outputs dark beer.