If you are requesting technical assistance with Twine, please specify:
Twine Version: 2.3.9
Story Format: Sugarcube 2.31.1
So I found a thread on here about how to make multi color links. That part works fine, but I’m trying to get the link to set a variable as well as advancing to the next passage. As I have it now, “Confidence Point” is in a specific color (here class=“confidence”) and I want clicking on the link to subtract one of the player’s confidence points.
<<if $you.confidence gte 1>>OR you could <<nobr>><a data-passage="monday 2-counseling2a" class="link-internal" tabindex="0"> SPEND a <span class="confidence">Confidence Point</span> to choose any of these options.</a><</nobr>><<set $you.confidence-=1>><<else>><</if>>
Problem is the Confidence Point is being automatically subtracted when the passage containing this link loads, not when the player clicks on the link. Any ideas?
I haven’t seen the original thread so am I not sure if you have tried with the <<link>> macro yet. If you can use it, try this:
<<if $you.confidence gte 1>>OR you could <span class="confidence"><<link "SPEND">><<set $you.confidence -= 1>><</link>></span> a Confidence Point to choose any of these options.<<else>><</if>>
Then in your stylesheet, put
.confidence a {color: purple}
or whatever color you need
Make sure to remove whatever style you had before.
yeah i tried the <<link>> macro and it didn’t work because I’m trying to get the <span class="confidence"> part within the link itself. Ideally, the link starts with the word “SPEND” and ends at the end of the sentence. The words “Confidence Point” would be the different class/color