twine 2.7.1 / sugarcube2.36.1
hi all! i’m in the process of revising one of my games and I’d like to include a character creator with a stat distribution system, similar to something like the [S.P.E.C.I.A.L.] points distribution system from fallout 4.
that being said, I’m in the process of creating a stat system that allows you to distribute ‘points’ to each character trait from a pool of existing points. now, I figured out how to get as far as the altering the numbers with something that looks like this – it changes the total value of points allotted to the strength stat, while also pulling from the total pool of points.
so far, my code looks something like this:
`:: cc`
`<<link "<-">>
<<set $strengthvalue -= 1>>
<<set $totalpts += 1>>
<<update>>
<</link>>`
`<<liveblock>>$strengthvalue<</liveblock>
<<liveblock>>
<<if $strengthvalue lte $totalpts and $totalpts gte 0>>
<<link "->">>
<<set $strengthvalue += 1>><<set $totalpts -= 1>>
<<update>>
<</link>>
<<elseif $strengthvalue gte $totalpoints>>
display null
<</if>>
<</liveblock>>`
`<<link "<-">>
<<set $luckvalue -= 1>>
<<set $totalpts += 1>>
<<update>>
<</link>>`
`<<liveblock>>$luckvalue<</liveblock>
<<liveblock>>
<<if $luckvalue lte $totalpts and $totalpts gte 0>>
<<link "->">>
<<set $luckvalue += 1>><<set $totalpts -= 1>>
<<update>>
<</link>>
<<elseif $luckvalue gte $totalpoints>>
display null
<</if>>
<</liveblock>>`
`<<link "<-">>
<<set $intvalue -= 1>>
<<set $totalpts += 1>>
<<update>>
<</link>>`
`<<liveblock>>$intvalue<</liveblock>
<<liveblock>>
<<if $intvalue lte $totalpts and $totalpts gte 0>>
<<link "->">>
<<set $intvalue += 1>><<set $totalpts -= 1>>
<<update>>
<</link>>
<<elseif $intvalue gte $totalpoints>>
display null
<</if>>
<</liveblock>>`
`<<liveblock>>$totalpts<</liveblock>>`
`:: StoryInit`
`<<set $strengthvalue to 1>>`
`<<set $totalpts to 15>>`
`<<set $luckvalue to 1>>`
`<<set $intvalue to 1>>`
This works alright, but as you might imagine–it never lets me get the pool from which I’m taking the points down to 0.
Now, I’m certain that there are better ways to achieve what I’ve described here and while I’ve been coding in twine for a little over a year now–I’d say I’m still fairly new to the language, so if anyone has any suggestions or ideas of what I could do to either fix this/a different way to achieve what I’ve described, I would be super grateful!
thank you!
[[ETA: code was a little jumbled in original post, just fixed tabs/spacing to make more readable]]