Howdy, Stranger!

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

Making a choice/link add to a stat value?

Hello, I've been trying to figure out how to add to the numbers I've set for variables.

For example, say we have a diligence stat of 5. And by clicking on a choice within the story, it could influence the number value assigned to that stat.

Like, if you choose to sleep in instead of waking up early, your diligence stat gets a -1 for sleeping in, and you get a +1 for getting up early.

Since I want to implement situations where the story can go different ways depending on how high or low certain stats are at certain points of the story, and if all choices lead to the same passage from the previous one, I can't just set it to add on to the variable once you arrive at the start of the passage.

I'm really new to using Twine, so I hope what I asked wasn't too confusing.

Comments

  • One way to do what you want is to combine a named hook which a (click:) macro, a (set:) macro, and a (go-to:) macro like so:
    Do you |sleep>[sleep in] or [get up]<getup|?
    
    {
    (click: ?sleep)[
    	(set: $diligence to it - 1)
    	(goto: "Next Passage")
    ]
    (click: ?getup)[
    	(set: $diligence to it + 1)
    	(goto: "Next Passage")
    ]
    }
    
  • Oh, wait nevermind, this works! I just messed up with capitalization!! Thanks for the help!
  • Sharing an alternative I came up with while working on the same thing.
    (set: $stat to it + 1)[[[displayed text|name of next passage]]]
    

    Simpler imo.
  • cyberdemon wrote: »
    Sharing an alternative I came up with while working on the same thing.
    One small issue with your solution, it does not work.

    If you include another Markup Link after your example targeting a different passage, and if you select this link and then check the value of your variable you will see that the (set:) macro is always applied.

    1. First passage.
    (set: $stat to 1)
    
    (set: $stat to it + 1)[[[displayed text|name of next passage]]]
    
    [[Click Me instead->Second]]
    
    2. Second passage
    Check the stat variable, it will equal 2 instead of 1.
    
    stat: $stat
    
  • greyelf wrote: »
    One small issue with your solution, it does not work.

    If you include another Markup Link after your example targeting a different passage, and if you select this link and then check the value of your variable you will see that the (set:) macro is always applied.
    Check the stat variable, it will equal 2 instead of 1.

    You're right, my bad. Except it's even worse... the stat isn't applied at all, for some reason. I'm thinking one of the - 1's in my passage is cancelling it out or something.

    Btw, using goto from one pass to another I don't see any arrows in the story-map between them (though the link works fine). Makes me feel OCD that it isn't there when it should be like ['s linking does like normal.
  • Both the Automatically Create Missing Passages and the Show Links Between Passages features only understand the standard Markup Link.
  • greyelf wrote: »
    One way to do what you want is to combine a named hook which a (click:) macro, a (set:) macro, and a (go-to:) macro like so:
    Do you |sleep>[sleep in] or [get up]<getup|?
    
    {
    (click: ?sleep)[
    	(set: $diligence to it - 1)
    	(goto: "Next Passage")
    ]
    (click: ?getup)[
    	(set: $diligence to it + 1)
    	(goto: "Next Passage")
    ]
    }
    

    This works by itself! But for some reason when I put it with other written stuff it doesn't work? I'm a bit confused as to why this is happening.
  • greyelf wrote: »
    One way to do what you want is to combine a named hook which a (click:) macro, a (set:) macro, and a (go-to:) macro like so:
    Do you |sleep>[sleep in] or [get up]<getup|?
    
    {
    (click: ?sleep)[
    	(set: $diligence to it - 1)
    	(goto: "Next Passage")
    ]
    (click: ?getup)[
    	(set: $diligence to it + 1)
    	(goto: "Next Passage")
    ]
    }
    

    This works by itself! But for some reason when I put it with other written stuff it doesn't work? I'm a bit confused as to why this is happening.
Sign In or Register to comment.