In my current project (using Sugarcube2/Twine v2.3.16), I have a cycle in a passage that determines whether the MC is the brother or sister of the character conversing with them. Obviously with this I’m wanting it to define whether the MC is a male or female, and set the variable accordingly at the same time, though I haven’t figured out how to do it in the same step. Here is what I have so far. First, the cycle itself (which is in the middle of some text):
<<if $genderselect is "sister">><<set $gender to "woman">>
<<else>><<set $gender to "man">>
<</if>>
As mentioned, what I’d like is to be able to combine both steps into one - making it that when you click on one it will set that variable with a value, and if you click it again it will replace that variable with its new value. OR, is it possible to have an external passage (like StoryInit) that I can put this code into and will actively track and set/change variables linked to the different passages (say, with the span id), so that the story passage itself isn’t cluttered with code?
What you’re describing sounds like a live change, yeah? Basically changing the stuff in real time, without passage transitions? If so, you need this custom macro:
It sounds like you’re only trying to detemine the gender of the main character. Thus you don’t need two story variables to do so. In every case you use a variable only to determine another variable you may wish to use a temporaray variable instead.
While not exactly what I meant, I used something similar to this (live changing of text on the same page, if I understood correctly?) in another of my projects, but it required more coding in the passage, so this could be a better alternative. Thanks for the suggestion!
This was exactly what I was after! I didn’t know a way to set the variable within the cycle to a value that was different to the label in the passage itself, hence why I used two variables. lol. Anyway, thanks so much for the help!