Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created August 8, 2022 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnighy/3221f83b55a6f1fad91cc3a8df764dab to your computer and use it in GitHub Desktop.
Save qnighy/3221f83b55a6f1fad91cc3a8df764dab to your computer and use it in GitHub Desktop.
RPGMV/RPGMZ save importer for browsers

Why this?

RPGMV/RPGMZ games can run on Web browsers, so you can upload your local copy of the game to somewhere only you can see and run it anywhere.

The problem is: the save data.

This small tool allows you to import the save data you uploaded into your Web browser.

How to use

  • Put this import.html under ./www folder.
  • Upload the folder altogether.
  • In the Web browser you want to use, open import.html under the URL of the game, and click the button.
    • Warning: all existing save data will be lost.
  • Open the URL of the game and start playing.
<script type="module">
const MAX_SAVES = 20;
const files = ["common", "config", "global"];
for (let i = 1; i <= MAX_SAVES; i++) {
files.push(`file${i}`);
}
const logArea = document.querySelector("#log-area");
function log(...args) {
console.log(...args);
for (const arg of args) {
logArea.innerText += `${arg}\n`;
}
}
const importButton = document.querySelector("#import-button");
importButton.addEventListener("click", async (e) => {
e.preventDefault();
try {
importButton.disabled = true;
log("Importing...");
for (const name of files) {
const key = `RPG ${name[0].toUpperCase()}${name.substring(1)}`;
const resp = await fetch(`./save/${name}.rpgsave`);
if (resp.status === 404) {
log(`${name}: not found`);
localStorage.removeItem(key)
} else if (resp.ok) {
log(`${name}: found`);
const text = await resp.text();
localStorage.setItem(key, text)
} else {
throw new Error(`Got ${resp.status} when fetching ${name}`);
}
}
log("Done.");
} catch (e) {
log(e);
throw e;
} finally {
importButton.disabled = false;
}
});
</script>
<button id="import-button">Import!</button>
<pre id="log-area"></pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment