So as a test to get used to ChoiceScript, I’m just writing a little test game and at the beginning in character creation, you can can choose three options from a list of traits. Instead of having “trait one, trait two, trait three” in the stats file, I had the choices get added into one variable just called traits.
My problem now is im trying to make a trait that required a previous trait to be chosen, so needing trait A to choose trait B, except they can only choose trait B if the only trait they have is trait A. If a player chooses trait C then trait A, or even trait A then trait C, they can’t choose trait B. Trait A has to be chosen first and trait B has to be chosen second and obviously that’s kind of annoying.
I hope i got my point across and I would be happy to try and explain more if needed
Is it necessary to package all your traits into one variable? I think assigning a boolean variable to each trait may be less of a coding headache.
From what I understand, you want trait A and trait C to be selectable without restriction and trait B to be selectable only if you have trait A (regardless of trait C). Correct me if I’m wrong.
There is a contains command here, which may help you with trait B, since it checks if trait A is present in the string rather than trait A being the exact string, which should solve your problem. (I haven’t tried it)
But personally, if you are just starting out, it is a lot easier to manage if you just create one true/false variable for each trait, then check if trait A is true when assigning trait B. Three simple variables will be easier to manage than one unwieldy variable. If you are testing traits later, it is easier if you can check a single true/false trait rather than trying to parse a mega string of traits to see if the player has trait X.
Okay so yeah, i was honestly over thinking it when a simple true/false system would have worked but now I’ve come across another issue. Using the simple inventory code on the choicescript stats.txt wiki page as reference, i made it so if one of the traits was true, it would automatically update the list of traits under stats to include it, but for some reason when ever you continue to the next scene the list of traits doubles itself. It’ll say “Traits: Trait A. Trait B. Trait C.” but when you go to the next scene it’ll say “Traits: Trait A. Trait B. Trait C. Trait A. Trait B. Trait C.” and im not entirely sure why it’s doubling it.
I have character creation in one scene using labels for the different sections and right after trait selection but before the next part of character creation, I have this code.
If you put this as your first lines of your choicescript.txt, then the conditions will fire every time you open “Show Stats” and reloads when you go to the next scene.
So, instead of putting them in choicescript.txt, have the conditions in the block after your traits choice.
ChanceOfFire’s answer did end up working in the end, unfortunately I was just kinda dumb. The problem was I originally put that code directly in the choicescript_stats.txt file which probably caused it to run every time it went to a new scene. I moved to code to the scene file itself but i forgot to save the new version of the choicescript stats file and only realized that after i had made my previous reply and since im new to the sight i couldn’t delete it or anything since It was pending. But everything seems to be good now.