[Harlowe 1.2.4]If Variable Has Certain Value, Go To Next Passage

0 votes
asked May 17 by Joshuareeves558 (220 points)
edited May 17 by Joshuareeves558
I am making a passage in which the player gets to click the stat(s) he/she wants to boost 3 times. There is a link for each stat which adds +5 to the corresponding stat and at the same time adds -1 to the number of choices you have left(you start out with three). I also wanted each link to be able to direct the player to the next passage once the number of choices was reduced to 0, but it hasn't been working. The link for boosting Strength is below.

(link: "Strength + 5")[(set: $str to $str +5)(set: $statchoice to $statchoice -1)(if: $statchoice = 0)[(goto: "CharacterDev5")]]

Thank you in advance.

2 Answers

+2 votes
answered May 17 by greyelf (97,410 points)
selected May 18 by Joshuareeves558
Best answer

Please use the Insert Code Snippet button when adding code examples to a question, it makes them easier to find and read.

In Harlowe a single equals sign '=' means assignment and is equivalent to the TO operator. To compare two values you need to use either the double equals signs '==' or the IS operator. This means that your (if: $statchoice = 0) statement is actually first assigned the value 0 (zero) to the $statchoice story variable and then checking if the end result is true, which it isn't.

I suggest changing your examine to something like the following:

(link: "Strength + 5")[{
	(set: $str to it + 5)
	(set: $statchoice to it - 1)
	(if: $statchoice is 0)[
		(goto: "CharacterDev5")


+1 vote
answered May 17 by Chapel (51,470 points)
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.