Okay, I'm new to twine and I've been playing around with some of the functions so that I can start creating a game with everything I want in it, but I can't figure out how to do math with the variables? It's better to show than explain:
<<set $str to 0>>
<<set $mag to 0>>
<<set $gold to 0>>
[[attack monsters for gold]]
<<set $str to += 5>>
<<set $gold to += 10>>
<<print $str>>
<<print $mag>>
<<print $gold>>
All of these show up as zeros!
I've tried many different things such as:
<<set $str = $str + 5>>
<<set $str += 5>>
<<set $str to ($str + 5)>>
But when I print it onto the screen, they appear as zeros. This is a very basic concept and I will be unable to create my game without it! I searched the forum for around two hours and found nothing. (Probably because it's so easy) Please help!
FIX: Right after I posted this, I found that the problem was the <<"set">>, the correct line of code for this is <<$str +=5>> I apologize for any time wasted. Although, I may have just helped a bunch of people who didn't understand this like I did.
Comments
This is actually the <<print>> macro's shorthand form. What you should note is that <<set>> changes values without printing them, and <<print>> prints values while either changing them or leaving them as they are.