- Part 1: Setup and Code 1
Part 2: Running Mates, Custom Themes, Candidate Colors
Part 3: Editing States, Starting Polling
Part 4:'Issue' Scores and Map Editing
Part 5: Questions, Answers, Advisor Feedback
Part 6: Answer Effects, Ending Codes, and Conditional Endings
Part 7: 'Choose Your Own Adventure.'
Part 8: Official Mod Loader Standards
Whoo boy, CYOA.
Step 20. Choose Your Own Adventure
'CYOA', 'Choose Your Own Adventure', or 'literally any custom js code'. This feature goes by many names. It is quite powerful, but used in a minimal manner in most mods. That's fine. Don't use CYOA just for the sake of it. This section is meant to understand CYOA a bit better.
You should take a look at the top of the Code 2. I have comments in the code - as shown with two slash symbols - that explains everything, but play through this tutorial and you should be good.
Both of these lines are (generally) needed to enable CYOA.
This line of code is crucial. All CYOA must be within a single function.
Next, the If statement. This is what determines which questions have CYOA. You need an IF statement, or something akin to it, like a SWITCH statement.
In the code, it says, IF ans==3805, then go to question 24. This is the question that sends the mod to the end. The next one says, IF ans=3086 OR 3902, go to question -1 (which is essentially restarting the mod)
The final one is IF ans==99999, go to question 8, which due to the rules of modding, goes to question 10. (If you want to know why, answer that question in the mod)
The bottom has an ELSE return False, which just means "if none of these criteria are met, AKA none of the questions answered need CYOA, just continue as normal"
Changing Questions Based Upon Previous Answers
This is the code from 2016 Democratic Primaries. Essentially, if your answer is 3501, which is where Sanders attempts to primary Obama in 2012, the question on Obama's legacy is changed signifigantly. This code is within the CYOA function inside the Sanders code. Put all your CYOA-only questions after the final question. Rather than jumping to around questions, like older CYOA, it's swapping out the cyoa questions. You can have as many questions as you wish change, and do this for multiple answers.
This is probably one of the most useful CYOA features. It's versatile, and allows you to set up major changes to the map early on.
Spoilers- but straight from 2016DNC as well. If you pick one of three answers for question 6, you'll have 30% chance that it leaks. It's use is more limited but I found this more enjoyable than regular RNG.
Optional: Re-enable Further Reading
Put this at the top of your Code 1. I would reccomend using Liquid Astro's further reading tool to make a fancy looking further reading tab. Citing your sourcs is always great.