Anyone know how to make achivements?

I’m working on a game and achivements would defineitly add to the overall gameplay. I’m looking for something like this:
https://qjzhvmqlzvoo5lqnrvuhmg-on.drv.tw/UInv/Achievements.html
The person I saw this from commented on a post on Reddit, but hasn’t responded to me. This is the comment:

1 Like

Please use the New Topic form’s “optional tags” field to state the name and version/series number of the Story Format you are using, as answers can vary based on this information. Based on the information in the linked reddit posting I will assume you are using the 2.x series of Harlowe.

The UInv Achievement example you linked to uses macros to extend the core functionality of the related engine, it also uses JavaScript to update the story’s History system and to achieve parts of the visual effect.

Harlowe doesn’t include some of the macros used within the UInv solution. Harlowe has also been deliberately designed to restricts an Author’s ability to use JavaScript, this specifically includes accessing internal parts of its engine like the History system.

So while it is technically possible to implement an Achievement system like the UInv one, such an implementation would require hacking into the story format’s engine.

note: ChapelR recently made available a “pre-release” of a framework that can be used to help do such hacking.

Heh… I just responded to you on Reddit, then came here in saw this. Go figure. :stuck_out_tongue:

I don’t know what Greyelf is talking about by a “UInv Achievement example”, since that code doesn’t use use UInv (my Universal Inventory System), and it doesn’t really use JavaScript for the effect, it’s mostly CSS triggered by SugarCube macros with a little jQuery in them.

Anyways, as I mentioned to you on Reddit, you can actually just right-click the link to that page, choose “Save linked content as…” to save the HTML file to your computer, and then import that HTML file into Twine to see the code yourself.

That said, I wrote that code before the State.metadata.* functions were added to SugarCube in v2.29.0, which make doing an achievement system much easier. So, if you’re using the SugarCube story format, you should definitely use those metadata functions, instead of the method I used with the <<remember>> macro, since the metadata isn’t tied to any particular save slot.

Hope that helps! :slight_smile:

The URL that the OP posted includes both UInv and Achievements in it, thus why I referenced it as the “UInv Achievement example”.

I said “parts” of the effect were achieved using JavaScript, and last time I looked jQuey was a JavaScript library thus making code like the following JavaScript.

<<set $("#achievement-title").text($args[0])>>
<<set $("#achievement-desc").text($args[1])>>
<<if $("#achievement-desc").height() > 80>>

If you are indeed using Harlowe, one of the examples for the Harlowe macro framework is an achievement system. See: https://twinelab.net/harlowe-macro-api/#/examples/achievements

Installation instructions: https://twinelab.net/harlowe-macro-api/#/installation-guide

As noted by Greyelf, the framework is in a pre-release state. It is mostly stable and feature complete as documented, but there are a few things I need to fine tune and it hasn’t seen a lot of usage yet so it still needs more testing.