0 votes
by (120 points)
So im doing a game based on decisions & consequences, and I want that every decision the player makes, counts for the ending result being a good or a bad one. Is there a certain code for something like that?

1 Answer

0 votes
by (159k points)

Please use the Question Tags (instead of the Question Title) to state which Story Format you are using, it makes it easier to search for questions related to a particular story format and it reduces the unnecessary padding of the title.

You can use a Story Variable to track the current $karma of the Player, and what is commonly known as a "Link with Setter" (or a "Setter Link") to increment the story variable each time a decision is made by them.

1. Initialise the Story Variable to its default value within your project's startup tagged special Passage.

You use the (set:) macro to assign a default value to the story variable.

(set: $karma to 0)


2. Use "Setter Links" within your projects passages to update the current value of $karma.

You use a (link:) macro to display each potential option, a (set:) macro to change the current value of $karma, and optionally a (go-to:) macro to send the Player to the next relevant Passage.

You come across a person collapsed on the side of the road, do you...

(link: "See what you can do to help them...")[
	(set: $karma to it + 1)
	(go-to: "Help Collapsed Person")
]
(link: "Walk past the person...")[
	(set: $karma to it - 1)
	(go-to: "Keep Walking")
]

warning: The above TwineScript was written from memory and has not been tested, it may contain syntax errors.

...