+3 votes
by (820 points)
I'm just curious about creating persistent achievement tracking, regardless of saved game. Right now, I have a system in place that will track achievements as long as the player keeps using the same save, but I also wanted to keep track of what endings they've gotten, too (and there's going to be a lot of them. start your bonfires, and prepare to died...). What I have would not work if a player wanted to run an entirely new save, or had multiple saves to follow different paths.

I had thought of using an external file, like a .txt file that the game updated on hitting an achievement or something, but I have absolutely NO idea if that's even possible, let alone how I would do it.

Anyone have any thoughts on how it might work, or other (probably better) methods?

(FYI: I had not planned this to be a hosted project, but rather a packaged set of files for download... unless it worked hosted somewhere, but that's well beyond the scope I'm aiming at for now.)

1 Answer

+3 votes
by (2.1k points)
selected by
 
Best answer

Since you're using SugarCube, you can try using the <<remember>> macro. It works functionally the same as the <<set>> macro except it stores the variable permanently in the browser. Something like

/*The player does something to acquire said achievement*/
<<remember $achieve1 = true>>


/*Later when checking achievements:*/
<<if $achieve1 == true>>
/*display whatever you want to display here*/
<</if>>

Just be careful and make sure to use the <<forget>> macro somewhere as well, in case you need to wipe the variable for any purpose. Or else during testing, you'll end up having the achievement permanently set to true when you need to test other things.

by (820 points)
edited by
Working perfectly!

Thank you, Echidna!

 

Muahahahahaha...

 

EDIT: Well, it WAS working until one of my test victims started using a different browser version, and another got irritable that his achievements will be bound to a browser instead of staying with his copy of the game.

This is going to take some more work, I guess.
by (63.1k points)

Note that, 

  1. You're still relying on the browsers local storage, so <<remember>> isn't permanent quite as permanent as one might hope. 
  2. In the good old sugarcane days, people abused <<remember>>. Other twine stories using that macro can overwrite your variable, so make sure the variable name is very precise, and maybe include your story's title in the variable name for good measure. 

Also, you should select @Superechidna's answer if it works for you, that way your question shows up green and everyone (like future people with the same question or people looking to help out) will know you got a satisfying resolution to your problem. Plus @Superechidna will get some fake Internet points for his trouble! 

...