Is there any way to make this code more efficient?

I’m planning a game where the gameplay is in between Ace Attorney Investigations and L. A. Noire, but in text. To give some context on how those games work, when you are investigating a location, you can look around and/or talk with someone to get more information.

Is anyone willing to take a look and streamline my coding? It’s about 250 lines long, and I did this in about two hours, so the script is awful. But this is how the code for the rest of the game will be structured like. Trying to keep it neat, too, so I can actually proofread it with eyeballs.

https://dashingdon.com/play/armadillidium/evidence-list-test/mygame/scenes/startup.txt

I don’t know if this is the most efficient way to use the code considering there are lots of repetitions (especially when interrogating a character, with the truth/doubt/accuse options, although not every piece of dialogue will have that when they’re obviously giving it to you straight - though doing it this way also means I can also customise the text every time if I wanted to), so any advice to streamline it would be appreciated!

You can collapse some of the choice options seeing as the only difference is the bold style of the text. For example:

@{false Bed | [b]Bed[/b] }

Since you don’t have anything inside the *else body, you can simplify it, like so:

From:

*if not (letter)
    *set letter true
    [i][b]Letter[/b] added to evidence.[/i]
    *line_break
    [i]This says her son died.[/i]
    *goto examine
*else
    *goto examine

To:

*if not (letter)
    *set letter true
    [i][b]Letter[/b] added to evidence.[/i]
    *line_break
    [i]This says her son died.[/i]
*goto examine

Other than that, your code is very well organized. There’s not much to give feedback right now. Unfortunately, ChoiceScript is rudimentary, so you can’t keep it DRY.

By your coding I can see you’re familiar with programming (with Python, perhaps?). Take a look at this cs library, there may be something that interests you there, especially the menu module. It can be helpful when building simple, repetitive choices.

5 Likes

Aww, thank you! That’s a compliment. I haven’t done programming before - except a previous WIP I guess, but that one was a total mess. This one feels easier to keep track of because that one was too big from the start…

If things are going to get repetitive anyway, might as well use it to expand and clarify on the choices, then. Give the player some idea before they jump into it. Also, Multireplace. I forget that exists. I need to learn how to use that.

All my writing so far is done with Sublime Text. CSLIB looks like a lot of… fancy usage of CS? I’ll take a look but it’s maybe over and beyond what I need as this is going to be a rather straightforward story.

Thank you!

1 Like

It’s doing rather fancy things “under the hood”, but to an end user it should only simplify and streamline things. It’ll certainly help your code stay DRY. But I appreciate there isn’t much in the way of tutorials or examples, so it can all appear a bit intimidating at first.

If you do end up using it, feel free to PM me any queries.

4 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.