Quick thing, I just realised I could do selectable if and if at the same time, and wanted to share it, even if many might already know But it’s gonna save me some time, so I thought I’d put it out here, and also ask what little tips and tricks y’all have found that you wish to share?
Examples:
*fake_choice
**General examples:**
*if (true)
*selectable_if (false) #Greyed-out choice but visible
*if (false)
*selectable_if (true) #choice not visible, but could be clickable
*if (true)
*selectable_if (true) #regular choice
*if (false)
*selectable_if (false) #It's just not there at all atp
**Implemented examples:**
*if (genderMC = "man")
*selectable_if (hasBook) #"As a gentleman and a scholar I feel like this book is trash—"
*if ((genderMC = "woman") and (some variable if you want))
*selectable_if (hasBook) #"As a lady and a professional I feel like this book is trash—"
**Regular use type examples:**
#"Books in general are interesting, I think..." (normal choice)
*if (false) #not visible choice etc
*if (true) #visible choice etc
*selectable_if (false) #greyed out choice
*selectable_if (true) #clickable choice etc
These can all be done on the same *choice section, and needs to have this indentation level.
Something I use a lot is a subroutine to test which major NPC likes the PC most. It might affect which character comes to see the PC for a chat, who wants to sit with them, or something else more branching. This one is from Royal Affairs.
For long branching paths, I write different files instead of having one massive file that holds every long branch. I then use a variable and a subroutine to call for the correct branch.
For the following example Job could equal “IT”, “CEO”, or “Factory”.
*gosub_scene {"Chapter4"&Job}
Also, if I ever need to check/modify a lot of variables, I’ll stack the order in reverse, so the first variable is at the bottom, and the last one checked is at the top. Then I’ll have it automatically loop back at the end back to the beginning to start all over. Only once it has checked the last option does it break the loop. This saves on having to type out the *goto in every *if statement and to not write out each variable check/modification individually.
In the following example, PowerName is set to "Teleportation" to start.
This is a genius idea for a thread. Thanks @Doriana-Gray
What is this, please?
I will add implicit_control_flow to the list. Create this variable in your startup, set it to true, and ChoiceScript will stop flagging errors if you don’t add a goto/finish/ending after every if/elseif/else statement. But only do this if you are sure you don’t need the training wheels of having the code flag the error so you have to think about where the code will go next each time.
This is a deliberate failure point introduced by the author with a message after it to explain what went wrong. In HarrisPS’ case this is to identify that the variable ‘closestclassmate’ was not set to a valid value before reaching that part of the code. Without it, the code may just have skipped the text or hit another error later on, both of which would be much harder to diagnose.
Omg. Gosh I really wish I knew about this earlier. I had tried to set them on the same line cause disable_reuse and if types went on the same line, and when it didnt work back then I just assumed it wasnt a thing. This is gonna save so much time and space!
Yep, I do this a lot to check for coding errors - it helps me spot problems that have arisen before the code, or within the code itself. Using it with RandomTest is invaluable, I couldn’t live without it for making these games that are this complex!
I’ve mentioned this before elsewhere, but nested multireplaces.
While snooping through an office, readers can go back to each place they’ve looked a second time to dig deeper. In one case, the issue is shorthand. If the MC passes a wits test, they recognize it as shorthand. If they don’t, they see only scribbles and it takes some doing to decipher.
*temp shorthand "@{(wits >= med_test) shorthand|scribbles}"
*choice
*if (cabinet_second = false) # @{(cabinet_first = false) Check the cabinet drawers.|Decipher the ${shorthand} in the file.}
Yes, I could have separated the first pass and second pass options, but I prefer keeping things together.
In complicated situations, breaking out nested IF blocks is usually the better bet, but when only a word or short phrase needs changing, this has been very useful.
You do need to watch for subject-verb agreement, though.
*temp fills "@{(wits >= med_test) fills|fill}"
[...]
@{(cabinet_second = true) Uric has written more shorthand commentary on the page.|$!{shorthand} ${fills} the margins.}