Harlowe - How to attribute points to a link so the user can accrue a score?

0 votes
asked Nov 8 by ADT036 (130 points)
Hi everyone,

I'm really new to Twine and an amateur when it comes to coding but hopefully, someone can still help me.... I've tried searching for an answer and I have found similar questions/answers but not anything that is near enough the same, or simple enough for me to understand/implement!

I'm creating a 'Choose your own adventure' style game where the 'player' can accrue points through choices they have made. I want the user to accrue or lose points once they've clicked on a link which updates a score that sits on every page. Is this even possible?

I've played around with some solutions but not found anything that has worked. Any ideas?

I'm using Harlowe 2.1.3

 

Thank you!

1 Answer

+1 vote
answered Nov 8 by Piply (380 points)
edited Nov 9 by Piply

Let's say one of your attributes is strength, with a baseline of 10. You could put this in your "Startup" passage,

(set: $strength to 10)

If you want the player's strength to change when clicking on links, you could do this,

(link: "You spend a couple hours doing heavy farm work.")[
	(set: $strength to it + 1)
	(go-to: "Go back to town.")
]

With a resulting total of 11 strength. Then use an if-statement to check how much strength the player has for ability checks. I'm sure there are better ways of doing this, but this is what I make do with. Note that you might not get those neat little grey arrows that connects passages in the overhead story view. I certainly don't and I would love to know how to fix that if someone more experienced could chime in.

commented Nov 8 by greyelf (36,930 points)

A link that updates one or more variables before traversing to another Passage is commonly known as either a "Setter Link" or a "Link with Setter"

@Piply: Your solution is the easiest way to create a "Setter Link" within Harlowe 1.x or 2.x

 

...get those neat little grey arrows that connects passages...

Unfortunately the Twine 2 Passage Map's "Determine Links Between Passages" and Passage Editor's "Automatic Create Missing Passage(s)" features only support the standard forms of markup based links no matter which story format you have chosen to use.

eg. standard markup based links:
 [[Link Text and Target Passage is the same]], [[Link Text->Target Passage]], [[Link Text|Target Passage]], etc...

There are a number of methods/hacks you can use to trick the above mentioned two features into supporting both advance markup based links (**) as well as macro based links but each method relies on unintended/undocumented behaviours of both the Passage Map and the Passage Editor components, and the main issue with using unintended / undocumented behaviours is that they can change or be removed without warning.

eg. Using a HTML comment element to fool the above mentioned components.

<!-- [[Next->Second]] -->
(link: "Next")[(go-to: "Second")]

... the above will both create the missing Passage as well as connect the two Passages but if changed only one of the Target Passage Name (Second) references and not the other then you would end up with the Map referencing one Passage and the run-time (during Playing) link referring another, and this could result in an error if the Passage that the run-time link references doesn't exist.

(**) like any of the SugarCube's Setter Link forms:
eg. [[Link Text|Target Passage][$variable to "value"]], etc...

commented Nov 9 by Piply (380 points)
Yeah, I've tried things similar to the workaround you mentioned, but, as you said, the side effects don't really make it worth dealing with in my opinion. It's just an aesthetic matter for me, so it isn't too important thankfully. I'd love a feature that allows us to draw simple lines and shapes.
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.
...