I am new to Twine and am having a little trouble with something, hopefully someone here can help.
I am building an RPG that works similarly to the Dungeons & Dragons 5e format. Most of what I want to include I have been able to figure out, but there are still some things I’m struggling with.
First some context, at the beginning of the game a player inputs their characters stats which will then give them bonuses throughout the game. I have used the following set-up to input the stats:
<<set $dex to 10>><<print $dex>>
( <<button “[+]”>><<set $dex++>><<replace “#stats-dex”>><<print $dex>><><>
| <<button “[-]”>><<set $dex–>><<replace “#stats-dex”>><<print $dex>><><> )
and I have calculated the bonuses like so:
<<if $dex == 16 or $dex == 17 >>
<<set $ste to 3>>
<<elseif $dex == 14 or $dex == 15>>
<<set $ste to 2>>
<<elseif $dex == 12 or $dex == 13>>
<<set $ste to 1>>
<>
<<set $ste to 0>>
<>
The problem I am having is actually applying these bonuses in game. I have set-up a way for the player to input a value and that value determines what happens next, but the value should be modified by the above bonus.
This is what I have so far:
What is your Stealth Roll? <<textbox “$stealth” “”>>
<<link “What Happens Next?”>>
<<if $stealth + $ste < 13>>
<<append “#result”>> <<goto [[You Have Been Found!]]>> <>
<>
<<append “#result”>> <<goto [[You Make it Through]]>> <>
<>
<>
The player inputs their value, then if that value + the bonus they gain from their stat is less than 13 they are taken to one passage, else they are taken to a different passage.
Unfortunately, it is not working. Instead of adding the 2 variables it is putting them together and checking if one of them is less than 13.
I think the problem is that my values are in the form of a string and I want integers/floats.
Does anyone know how to do this? Is there a better/different way to do this?