Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Assigning Stats

I think I'm in the right place for this question. If not, please let me know.
Okay, into the question: How can I set up an initial stat assignment? And I'm using Harlowe btw.
I just started using Twine 2 for my courses in Game Design. I love Twine and have so many great ideas that I want to keep working on this story I'm making even after the assignment for school is done. So, I've set up stats for the player to have that I want to have checks later on for and I can't seem to find anything by searching that will help me set this up properly. So far I have this:
<img src=""; />
This is the page where stats are explained to the player/reader and then they get to choose which stat they want their first (out of three) initial points put into. Once the player clicks one of these it'll go to this page:
<img src=""; />
However, when I test this Second Point page I get this:
<img src=""; />
I clicked Strength as the first point so what I wanted to happen is it read:
Strength (2)
Intelligence (1)
Dexterity (1)
Endurance (1)
Agility (1)
Speed (1)
Instead, it's apparently changing ALL the stats to 2 instead of only the stat clicked in the first point assignment page.
Perhaps I'm missing something stupidly simple but like I said, I just started working with Twine 2 and I'm honestly proud of how far I've gotten so far. Am I maybe missing something like "if this is clicked then add 1 to $str? Because in debug mode I'm seeing it running all of those (set:$stat to $stat+1) instead of only the one being clicked.


  • Two things before I get into the answer.
    1. You should always state the story format you're using and its version, because advice will tend to vary based on that information. Sames goes for the version of Twine you're using—though you should also include information about your OS.
    2. If you're asking for help with code, post the code itself, not screenshots of it. When you do, please use the code tag when posting code or markup—it's C on the editor bar. Posting screenshots, in addition to code, can be helpful to document things you're seeing, which may not be readily obvious from the code alone, but they're not a substitute for the code itself.

    Your chief issue is that you're placing the (set:) within the link text portion of the links, which are processed as the link is being constructed, not when the link is activated. That should be obvious if you think about it for a second—if they weren't processed immediately, how could Strength($str) possibly hope to show the current value of $str.

    In other words, the following constructs:
    [[Strength(set:$str to $str+1)|Second Point]]
    [[Strength($str)(set:$str to $str+1)|Third Point]]
    Are equivalent to these:
    [[Strength|Second Point]](set:$str to $str+1)
    [[Strength($str)|Third Point]](set:$str to $str+1)
    Beyond that, I'd get into the habit of using space within your macros and learning what the it keyword does within (set:).

    What you want to use here is something which will only execute the (set:) when the link is activated. One way to do so would be with a combination of the (link:) and (goto:) macros—in addition to (set:). For example:
    (link: "Strength")[(set: $str to it + 1)(goto: "Second Point")]
    (link: "Strength($str)")[(set: $str to it + 1)(goto: "Third Point")]

Sign In or Register to comment.