Things I wish I'd known writing my first ChoiceScript game (+ add yours)

Okay! Here’s what I’ve learned using ChoiceScript for a little over a year now.

Notepad++

I’ve tried CSide, but I found it too lacking in customization and not optimized for my visual impairment. I switched to Notepad++ for the following reasons:

  • Macros, or recorded keystrokes that simplify typing repetitive words.
  • Vivid colors to help me visually distinguish code.
  • Ability to add code and keyword colors.
  • Notepad++ records all used words, so I’ll type in label_label_name to easily find all labels I’ve used in a file. Or temp_temp_name to find all temporary variables.

Here’s what a game looks like in Notepad++ for me. Keep in mind I’ve changed the font for a more legible mono font, and I use bizarre colors because of photosensitivity.

image

Using Comments

I use *comment all over the place. I’ve tagged all used comments with different keywords to help me find them at a glance and to know which ones to remove for a public build.

I use *comment to add in table of contents, quick jump to most commonly used labels, and visually distinct borders. All while creating the game; these will be deleted on submission.

Variable Names

Having coded prior, I hated when my teachers said keep variable names simple. I got frustrated shrinking my thoughts into a couple words. My variable names are long and fully indicative of whatever I pull them for. To help organize them, all variables have a distinct naming theme.

Booleans are usually written so that it reads well in an *if statement, such as has_pc_opened_door or pc_investigated_the_morgue.

Variables use name_pts or name_score to indicate to me that I’ve used numbers to track them.

For strings, I use name_st or name_description.

I know it’s not standard, but it helps my brain immensely and removes confusion.

Normalizing Stat Adjustment

Kinda niche, but I create systems of when each variable gets updated within a row. Or which variable gets priority when updated. That way, code readers get a consistent reading experience, I know where to look immediately, and I can leave and return to my code after a while and know what I’ve done.

I’m a very linear person, I guess.

Making Code Readable

This is also pretty niche, but I’ve grown used to coding with numbers more so than words. A lot of my earlier games used number variables, which made it harder for readers to understand what was happening.

I’d code *create pc_hair 4, *set ro_mood 5, or *if (room_status >= 4) and would never use strings unless I wanted the code to be printed for the player. Numbers just made more sense to me.

To help with this, I intentionally throw in strings alongside with numbers or make variables tracked as strings so players can have a sense of what’s going on. It… makes it a bit harder for me, though. Haha.

Empty Spaces, If Statements, And Multireplace

Mostly unique to having implicit_control_flow set to true, you can use these options to create a more dynamic reading experience. In as few words a possible, HTML breaks down lines and spaces, so you can combine lines of code or paragraphs.

In this example, you can make a choice response feel more natural as it blends into a paragraph without having to rewrite extra words:

image(s)

Using this code…

Will print like this in-game.

Using a well-placed enter, if statement, or multireplace can make it feel more immersive when the player’s choices are reflected in the game. You can even use them in choices, too!

There’s a bit more I want to say, but does this make sense? :slight_smile:


m

I apologize. Authors come from wide ranges of coding backgrounds and technical expertise. I really look up to you and your published works (and your insights).

13 Likes

I do use multireplace for simple things, like changing is/are for the them pronouns, or substituting civilian names for hero names once you know them well enough, but generally I am not fond of them. It’s not that they are hard to write, but for me, they are hard to read. And I read my code so often that I prioritize easy readability over everything else.

10 Likes

For small things, I much prefer the look of

You put on your @{costume coat|dress|robe} but the @{costume buttons don't|zipper doesn't|belt doesn't} do up properly

to:

You put on your
*if (costume = 1)
  coat but the buttons don't
  *goto do_up_properly
*elseif (costume = 2)
  dress but the zipper doesn't
  *goto do_up_properly
*elseif (costume = 3)
  robes but the belt doesn't
  *goto do_up_properly
*label do_up_properly
do up properly

Implicit control flow makes it look a little nicer but it still breaks the flow for me!

8 Likes

I guess it depends on how folks tend to handle micro-branching? I have a similar thing to Malin where I find it harder to parse multireplace when I’m reviewing a scene’s pacing, but that’s normally because when I do micro-reactivity, it still consists of a line or two rather than a few words - so it gets increasingly difficult to parse how each permutation of a scene is paced when every permutation is embedded into a single multireplace.

That has made me leery of using multireplace too much, despite being perfectly comfortable with it from a code perspective - that said, I probably should use it more than I do.

4 Likes

Really! I’m curious which other programming languages you mean. I didn’t mean to suggest that it was original to CS or ink, just that it operates in a similar manner to ink, for similar design goals.

1 Like

I’m still working on my first choicescript game, but the one thing I wish i figured out earlier was gosubs. I didn’t figure out how to properly use one until chapter 3 of my current WIP and its been a big game changer in addition to figuring out multireplace with chapter 4.

Although I do have a strong preference for gosub_scene over just gosub. I don’t like having to scroll through my chapters to find the continuation of a scene, but also in my second chapter there’s a section of 1,000-1.5k words thats copy pasted 3 times that really should have just been a gosub if I knew what i was doing back then.

I would second this. If i wasn’t periodically checking the writer’s support thread, I would never had figured put what it was. Even coming across it in the code of other games, I was more confused than anything else and would have been too intimidated to try to figure it out on my own.

5 Likes

Be careful; on Firefox browsers, too many redirections causes a game crash.

3 Likes

Just be careful with ${his}, since you may be tempted to use it for both “his table” and “that table of his.” If you say a female character’s ${his} = “her” that would come out as “her table” and “that table of her” (when it should be “hers”). Same too with “their” vs. “theirs.”

9 Likes

Pretty much any high-level language. Multireplace has two functionalities that use virtually the same syntax: index access and a ternary operator (if-then-else).

JavaScript below:

// ternary
const hp = 12;
const status = `You are ${(hp > 0) ? "alive" : "dead"}.`;

// index access
const directions = ["north", "east", "south", "west"];
const facing = `You head to ${directions[2]}.`;

Choicescript equivalents:

*create hp 12
You are @{(hp > 0) alive|dead}.

*create direction 3
You head @{direction north|east|south|west}.
2 Likes

Ah, I see what you mean. Yeah, fair enough!

1 Like

Ha, no apology needed. I always knew who I was. There are coders who write and writers who code. I am definitely not the former.

@cup_half_empty Thanks! Crazy to think where I was nine years ago compared to now.

6 Likes

Yep. It’s there on my Nepal-bought laptop and so easily usable when I switch to the manufacturer config (US). But for some reason the remapping to “UK keyboard” prioritizes some extra currency symbols instead (edit: and the ¬ character for some odd reason!). And after a few decades in the UK I’m too accustomed to the UK location for e.g. quotes to stick with US.

Pretty sure my wife’s laptop, manufactured in the UK, has a pipe key in a readily findable location. :slight_smile:

3 Likes

I’m absolutely still learning, but I love seeing everyone’s approach/hacks for inspo. You can write something beautiful without most of the suggestions. Part of the fun of CS/IF for me is the ongoing learning. I have miles to go but appreciate how generously this community shares.

12 Likes

Yep, hers and his I have to handle in normal code. They are rare enough that doesn’t bother me.

3 Likes

This is a very good point that never occurred to me (probably some kind of quartz effect), so thanks for making it. I’ll keep this in mind.

6 Likes

I am using variable genders for every main character in my game, and the way I’ve done it is by not using “his” as the name of the variable, because it does double duty, and instead picking a gender where each version of the pronoun is different.

Personally, I like e/em/ers. It’s a group of pronouns I really like, they’re all really short to type, and they’re all distinct. So in the example above, it would be:

${er} table, and that table of ${ers}.

The possessive pronoun (ers/hers/his/theirs etc.), the object pronoun (er/her/him/them etc.), and the subject pronoun (e/she/he/they etc.) are all different.

Same is true of ‘she’ and ‘they’ of course, but they take longer to type. Also, if I am typing a particular pronoun each time, I find I tend to think of all my characters as having that gender, even if I am typing it in curly brackets. What i love about e/em/ers is that each of those words makes me think of a different one of the three most common genders, so I am constantly revisiting my gender preconceptions for the character. ‘E’ makes me think of ‘he’, ‘em’ makes me think of ‘them’, and ‘ers’ makes me think of ‘hers’. And because it isn’t actually any of these, it also resists my unconscious attempts to apply gender norms to my characters better.

Also, it means I have got my characters’ separate pronouns down to a minimum number of letters. My character Ferhan’s subject pronoun, for example, is ${fe}. So short!!

10 Likes

“She” pronouns capture the her/hers distinction but not the his/him one (possessive adjective vs object pronoun). “Them” pronouns catch all the distinctions (I think?) but are as you note longer to type. I like your solution a lot.

Mine was to go with masc pronouns (because I use possessive adjectives a LOT more than possessive pronouns) and femme nouns-- so ${woman}, ${lass}, ${daughter} etc. for nouns the NPCs might use when referring to the MC. I think that mix has been helpful in my effort to avoid the subconscious pull of the pronouns toward writing an unduly gender-specific MC.

I thought I could write completely without “hers/his/theirs” at first, but finally gave up late in Game 1 and threw a ${hers} variable into the mix for the rare occasion when it’s needed.

A ${her} variable for a male character will have the same problem distinguishing between “call ${her}” and “${her} phone” that a ${his} variable would between “${his} phone” and “that phone is ${his}.”

Contrast “call ${them},” “${their} phone,” “that phone is ${theirs}.” Or in your much pithier case, em/er/ers.

Fair enough. My thought is that if you can write a gender selectable MC that isn’t a completely generic blank slate, you can write a gender selectable RO. But YMMV.

7 Likes

Can’t work out which ‘she’ form duplicates where another doesn’t. If you can be bothered, can you give me an example?

Oh, I like the idea of using ‘male’ for pronouns and ‘female’ for gendered terms. Though i suspect I would end up using the pronouns a lot more than words like “daughter” or “man”. I kind of sidestepped that in this game by just not using any gendered language whatsoever. Everyone is “person”, all offspring are “child” and so on. I haven’t decided how I feel about it though. It means the only gender markers in the entire game are pronouns, and I’m not sure that’s enough for players to feel able to inhabit their gender in the story. I’m hoping to get some feedback on how it feels at some point.

3 Likes

I can’t wrap my head around gender selectable ROs. Props for you guys for coding theme. I’ll try to keep in mind your advice.

4 Likes

Right? You’d think it’d be simple, but my brain always views gender selectable ROs as three separate people, thus tripling the cast.

I like it best when ROs are gender-stagnant so that I can better predict their responses. I guess, for me, I’d rather not just use swapped words but a complex reaction based on gender and social dynamics of both parties. I don’t understand keeping reactions the same but swapping out words.

That said, I’m going to make one gender selectable RO for practice in my WIP. I’m keeping a close eye on your advice. :slight_smile:

5 Likes