Possibly a bit easier, you could use the $Achievments variable to store any information about achievements in the game or unlocking "new game +" using the <<remember>> macro (instead of the <<set>> macro).
To make that work optimally, first, in your StoryInit passage, put this:
<<if ndef $Achievements>>
<<remember $Achievements = {}>>
<</if>>
That will make sure that the $Achievments variable is initialized as an object if it doesn't already exist, and then it will remember it even when a new game is started or loaded.
And then add this to your JavaScript section:
Config.saves.onLoad = function (save) {
// Make sure Achievements are preserved, even if an old save is loaded.
if (save.state.index >= 0) {
var SaveVars = save.state.history[save.state.index].variables;
if (State.variables.hasOwnProperty("Achievements")) {
if (SaveVars.hasOwnProperty("Achievements")) {
// Update Achievements if necessary.
var Keys = Object.keys(State.variables.Achievements), i;
for (i = 0; i < Keys.length; i++) {
SaveVars.Achievements[Keys[i]] = clone(State.variables.Achievements[Keys[i]]);
}
State.variables.Achievements = clone(SaveVars.Achievements);
$.wiki('<<remember $Achievements>>');
} else {
// Add Achievements.
SaveVars.Achievements = clone(State.variables.Achievements);
$.wiki('<<remember $Achievements>>');
}
} else {
if (SaveVars.hasOwnProperty("Achievements")) {
// Make sure saved Achievements are remembered.
State.variables.Achievements = clone(SaveVars.Achievements);
$.wiki('<<remember $Achievements>>');
}
}
}
};
That will make sure that, even if you load an old save, it won't remove any data from the $Achievments variable. However, it will change any values to match the (possibly older) saved values, thus it's best to only add properties to the $Achievments variable which will remain unchanged once set (e.g. if you add a property and set it to true, it will then it should always and only be set to true after that).
Now that you've done all that, marking that an achievement, like New Game+, has been unlocked is as easy as this:
<<remember $Achievements.newGamePlus = true>>
and you could check that using:
<<if $Achievements.newGamePlus>>
/* code for if $Achievements.newGamePlus is true here */
<<else>>
/* code for if $Achievements.newGamePlus is not set or is false here */
<</if>>
Just make sure that instead of using <<set>> when changing the $Achievments variable, you always use <<remember>> instead, and that will let you keep all of the data on the $Achievments variable across saves.
Enjoy! :-)