In my game i want to have a system where a user presses a button and it gives them a base64 string that they can enter on another computer to get there save data.
var cash = 2228
var seeds = 0
var Final = 0
var encodedData
var decodedData
var decodeLoad
//Function here where user inputs encoded data and sets it as the encodedData Variable
function savedata() {
encodedData = window.btoa("['"+ cash + "'], ['" + seeds + "'], ['" + Final + "']");
}
function loaddata() {
decodedData = window.atob(encodedData);
decodeLoad = decodedData
}
When the user with this save data of 2228 cash, 0 seeds and 0 Final they will get a string that looks like this
WycyMjI4J10sIFsnMCddLCBbJzAnXQ==
when that goes through the load data function it comes out as a string formatd like an array
"['2228'], ['0'], ['0']"
I then want that string to be used as an array and then the values be put into the correct variables (First one to cash, second to seeds, third to final).
Here is a snippet to show that code block in action (You can change the first 3 variables to get different results:
var cash = 2228
var seeds = 0
var Final = 0
var encodedData
var decodedData
var decodeLoad
function savedata() {
encodedData = window.btoa("['" + cash + "'], ['" + seeds + "'], ['" + Final + "']");
}
function loaddata() {
decodedData = window.atob(encodedData);
decodeLoad = decodedData
}
savedata()
loaddata()
document.write("Encoded: " + encodedData + "<br>Decoded: " + decodedData)
So Is it possible?