You'll need to do a bit more than that. Here's the code:
window.promptOnce = window.promptOnce || function (msg, def) { // we need two args now for prompt
var ret; // we need a return variable
try {
if (window.sessionStorage) {
var store = window.sessionStorage;
}
if (store.getItem('twine-prompt-flag') !== 'true') {
// change the flag's name to not step on `alertOnce()`
ret = prompt(msg, def);
store.setItem('twine-prompt-flag', 'true');
}
} catch (ex) {
console.error(ex);
ret = prompt(msg, def); // prompt anyway
} finally {
ret = (ret) || ''; // harlowe flips out if the user cancels the prompt, this should fix that
return ret; // return the input from the prompt
}
};
Usage:
(set: $var to promptOnce('Please enter your name:', 'Luke Skywalker'))
I detailed the changes I made in comments, so maybe that'll give you a little bit of insight if you're interested.