Deploying to pages from @ thepaperpilot/thepaperpilot.github.io@91ffe25fd6 🚀
This commit is contained in:
parent
4de3b9bf94
commit
bb365c434a
879 changed files with 55528 additions and 0 deletions
the_ascension_tree/js
45
the_ascension_tree/js/saveload.js
Normal file
45
the_ascension_tree/js/saveload.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const SAVENAME = "tahperaislcfeonodlesd";
|
||||
|
||||
function local_save() {
|
||||
localStorage.setItem(SAVENAME, JSON.stringify(player.save()));
|
||||
}
|
||||
|
||||
function local_load() {
|
||||
if (SAVENAME in localStorage) player.load(JSON.parse(localStorage.getItem(SAVENAME)));
|
||||
}
|
||||
|
||||
function hard_reset(seed) {
|
||||
localStorage.removeItem(SAVENAME);
|
||||
player.reset(seed);
|
||||
player.current_layer.selectLayer();
|
||||
}
|
||||
|
||||
// those two are not used
|
||||
async function import_save() {
|
||||
player.load(JSON.parse(atob(await navigator.clipboard.readText())));
|
||||
}
|
||||
|
||||
function export_save() {
|
||||
navigator.clipboard.writeText(btoa(JSON.stringify(player.save())));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
function exportToClipboard() {
|
||||
navigator.clipboard.writeText(document.getElementById('export_save').value);
|
||||
}
|
||||
|
||||
function importFromClipboard() {
|
||||
navigator.clipboard.readText().then(clipText => document.getElementById('import_save').value = clipText);
|
||||
}
|
||||
|
||||
function importSave() {
|
||||
let backup = player.save();
|
||||
try {
|
||||
player.load(JSON.parse(atob(document.getElementById('import_save').value)));
|
||||
closeModal();
|
||||
}
|
||||
catch (e) {
|
||||
player.load(backup);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue