Implementing passworded content in a Twine work
It's not terribly difficult to implement passwording in a Twine work. First, you'd drop this into your story javascript passage:
/* hashStr - Start */
window.hashStr = function(txt) {
var hash = 0, i, chr;
if (txt.length === 0) return hash;
for (i = 0; i < txt.length; i++) {
chr = txt.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
/* hashStr - End */
Next, you'd need to go here (or message me and I'll help you) and use the Enter text here textbox to enter the desired password. For example, if your desired password is redrum, the hash will return -934876071 Copy that number to the clipboard, because we'll use it in the next step.
Step 3: Finally, you'll need to put the following code into a Twine passage and specify the number you got in step 2. This is a textbox where users can try to enter the correct password:
You can view the raw text here, online...
→