0 votes
by (300 points)
What I want to do is have a variable increase based on which option is picked in a certain room. I know that variables can be set with:

(set: $variable to " ")

But that doesn't quite work for what I'm trying to do. For example, if you choose to: [[Help Grandma cross the road]], then your "goodkarma" would increase by 1 without me having to set the number it increases to myself.

Any advice would be great, thank you!

1 Answer

+1 vote
by (158k points)
selected by
Best answer

You would first initialise your story variable within your project's startup tagged special passage like so.

(set: $goodkarma to 0)

You would then use a (link:) macro based 'Setter Link' like the following to increase the story variable's value.

What do you want to do?
(link: "Help Grandma cross the road")[
  (set: $goodkarma to it + 1)
  (go-to: "Help Grandma cross the road")


Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.