Hello, please tell me what you need to do to integrate external save into the web version of the project?
Transferring saves from desktop to web version
RPG Maker MV SupportIt would've been better if you gave a little more info about your problem but I'm guess you want to use desktop saves for web games?
I'm not sure I'm informed enough to respond but in case nobody does... here's what I think-
Web version save files are saved in the local storage. You can't physically take the save files and drop them somewhere but there's this part in rpg_managers:
StorageManager.saveToWebStorage = function(savefileId, json) {
var key = this.webStorageKey(savefileId);
var data = LZString.compressToBase64(json);
localStorage.setItem(key, data);
};
If you can extract the contents of your desktop save file, then you can pretty much use this function here to transfer the save to the web version.
I'm not sure I'm informed enough to respond but in case nobody does... here's what I think-
Web version save files are saved in the local storage. You can't physically take the save files and drop them somewhere but there's this part in rpg_managers:
StorageManager.saveToWebStorage = function(savefileId, json) {
var key = this.webStorageKey(savefileId);
var data = LZString.compressToBase64(json);
localStorage.setItem(key, data);
};
If you can extract the contents of your desktop save file, then you can pretty much use this function here to transfer the save to the web version.
@Hyouryuu-Na, I need help lol is that descriptive hahaha.
Anyhow, please give us more details. Sometimes, it is complicated.
Anyhow, please give us more details. Sometimes, it is complicated.
Let me explain the case itself.
My comrades are testing the game through a browser, it is more convenient for them, since everyone has different os and it is not always possible to download individual versions.
In order to make it easier to test different quests, I prepare a save file before each quest. But my comrades don't see them in the browser. Is there any way to export save files from the desktop version to the browser version? Even if for this they will have to run some script in the browser console.
My comrades are testing the game through a browser, it is more convenient for them, since everyone has different os and it is not always possible to download individual versions.
In order to make it easier to test different quests, I prepare a save file before each quest. But my comrades don't see them in the browser. Is there any way to export save files from the desktop version to the browser version? Even if for this they will have to run some script in the browser console.
@Klimber I figured you wouldn't need anything too complex so here you go:
Put this as a script anywhere in your game:
What you have to do is- give them the save files. Share them anyhow you like. Your players have to open it with a text editting program (Or you can just paste the save contents yourself if you're communicating in a chatroom or anything like that). Then they have to copy the entire thing. Then they will run this script ( through an event) It'll ask them which save slot to save this content in. They can just paste the contents into the box. When they click yes, the file will be saved to their web storage. Then, they have to hit F5 to refresh the game. Next times they open the game, they will see the new Save File in the Load menu. Make sure to give them the global.rpgsave too.
Put this as a script anywhere in your game:
JavaScript:
var ID = prompt("Save file ID to save to: ")
var saveContents = prompt("Save file contents: ")
var key = this.webStorageKey(ID);
localStorage.setItem(key, saveContents);
var globalContents = prompt("Global file contents: ")
StorageManager.save(0, globalContents);
What you have to do is- give them the save files. Share them anyhow you like. Your players have to open it with a text editting program (Or you can just paste the save contents yourself if you're communicating in a chatroom or anything like that). Then they have to copy the entire thing. Then they will run this script ( through an event) It'll ask them which save slot to save this content in. They can just paste the contents into the box. When they click yes, the file will be saved to their web storage. Then, they have to hit F5 to refresh the game. Next times they open the game, they will see the new Save File in the Load menu. Make sure to give them the global.rpgsave too.
@Hyouryuu-Na I ran the script both separately in the console and in the web project, but the game constantly throws the same error, regardless of what was entered in the pop-up line:
Can you give me an example of what to write in pop-up messages?
Can you give me an example of what to write in pop-up messages?
EDIT : Bargle. Too sleep deprived. I went the wrong direction with the saves.
@Klimber
I made a stupid mistake. Now it should work:
Instructions are same as before.
NOTE!!! Global was not overwriting for some reason... It's saved and you can still read it with localStorage.getItem but it's not working for the game itself... so your players will need to make a save first and then use this script to overwrite that save (same save slot) i.e they can't save to a completely new save slot. That save slot must have prior saves.
Those popup windows could be of three types afaik. Alert, prompt and confirm. If you want to get input from the player, you can use prompt. If you just want to give them a message, you can use alert. And confirm is for ok cancel sorta stuff. I don't really like these as they're a seperate window outside the game. So they sorta break immersion.
Anyways, for prompt, it's like,
The message you want to give the player is shown and their input is stored to a variable (here, it's x). The variable can be a game variable too.
I made a stupid mistake. Now it should work:
JavaScript:
var ID = prompt("Save file ID to save to: ")
var saveContents = prompt("Save file contents: ")
if (saveContents!=null){
StorageManager.saveToWebStorage1 = function(ID, saveContents){
var key = this.webStorageKey(ID)
localStorage.setItem(key, saveContents);
}
StorageManager.saveToWebStorage1(ID, saveContents);
}
else{alert("Save Contents is null. Data won't be saved.");}
NOTE!!! Global was not overwriting for some reason... It's saved and you can still read it with localStorage.getItem but it's not working for the game itself... so your players will need to make a save first and then use this script to overwrite that save (same save slot) i.e they can't save to a completely new save slot. That save slot must have prior saves.
Those popup windows could be of three types afaik. Alert, prompt and confirm. If you want to get input from the player, you can use prompt. If you just want to give them a message, you can use alert. And confirm is for ok cancel sorta stuff. I don't really like these as they're a seperate window outside the game. So they sorta break immersion.
Anyways, for prompt, it's like,
JavaScript:
var x = prompt("message");
Original thread: https://forums.rpgmakerweb.com/threads/transferring-saves-from-desktop-to-web-version.125176/