Page 1 of 1
Save Games Help
Posted: Sat May 22, 2021 12:28 pm
by intermolecularpyro
Hi everyone, me again asking yet another question about Eos.
I'm pretty much finished my first tease, but the last thing I need to do is store stuff across multiple sessions.
I've got several point values, and in my initial script, everything starts at 0. I want to be able to save their value across sessions so that when you exit the tease and go back in, they don't reset to 0 again.
I'm totally lost with actually doing it though, I've looked at the tutorials and through the forums but I can't seem to find an answer.
Probably just missing relatively simple though right?
Hope one of you can help!
Re: Save Games Help
Posted: Sat May 22, 2021 12:45 pm
by Shattered
1. Options -> Storage -> On
Init Script, for each variable -
var userTutorialcomplete = teaseStorage.getItem('tutorialcomplete');
replace userTutorialcomplete with the name of your variable, and set tutorialcomplete to something else - I like to use the same word but with user in front for simplicities sake.
Then when you set the variable in the tease with an eval clause, e.g.
userTutorialcomplete = 1
Then have a new eval clause (can use the same one I think, but I like it seperate) saying
teaseStorage.setItem('tutorialcomplete', userTutorialcomplete)
And that (mostly) works for me!
Re: Save Games Help
Posted: Sat May 22, 2021 1:15 pm
by intermolecularpyro
Thanks for your help. I think I get it. Just want to check a couple of things before I go ahead and do it.
So my initial script at the moment looks something like this:
value1 = 0
value2 = 0
value3 = 0
Would it be ok to replace it with:
var value1A = teaseStorage.getItem('value1');
var value2A = teaseStorage.getItem('value2');
var value3A = teaseStorage.getItem('value3');
Or would it be the other way around?
var value1 = teaseStorage.getItem('value1A');
var value2 = teaseStorage.getItem('value2A');
var value3 = teaseStorage.getItem('value3A');
Then, if I want to save these values only on a certain page, rather than when they are changed or set, would I use:
teaseStorage.setItem('value1', value1A)
or
teaseStorage.setItem('value1A', value)
on that page?
I hope this makes sense.
Sorry for the extended questions, just want to get it right!
Re: Save Games Help
Posted: Sat May 22, 2021 3:02 pm
by Shattered
intermolecularpyro wrote: Sat May 22, 2021 1:15 pm
Thanks for your help. I think I get it. Just want to check a couple of things before I go ahead and do it.
So my initial script at the moment looks something like this:
value1 = 0
value2 = 0
value3 = 0
Would it be ok to replace it with:
var value1A = teaseStorage.getItem('value1');
var value2A = teaseStorage.getItem('value2');
var value3A = teaseStorage.getItem('value3');
Or would it be the other way around?
var
value1 = teaseStorage.getItem('value1A');
var
value2 = teaseStorage.getItem('value2A');
var
value3 = teaseStorage.getItem('value3A');
Then, if I want to save these values only on a certain page, rather than when they are changed or set, would I use:
teaseStorage.setItem('value1', value1A)
or
teaseStorage.setItem('value1A',
value1)
on that page?
I hope this makes sense.
Sorry for the extended questions, just want to get it right!
var
value1 = teaseStorage.getItem('value1A');
var
value2 = teaseStorage.getItem('value2A');
var
value3 = teaseStorage.getItem('value3A');
teaseStorage.setItem('value1A',
value1)
Re: Save Games Help
Posted: Sat May 22, 2021 4:03 pm
by intermolecularpyro
Awesome, thanks for the clarification.
Pretty certain I'm doing it right. Is there any way to test that this part works before publishing? Or do I have to trust I've done it correctly?
Thanks again!
Re: Save Games Help
Posted: Sat May 22, 2021 4:55 pm
by Shattered
intermolecularpyro wrote: Sat May 22, 2021 4:03 pm
Awesome, thanks for the clarification.
Pretty certain I'm doing it right. Is there any way to test that this part works before publishing? Or do I have to trust I've done it correctly?
Thanks again!
Load the tease in a seperate browser, open the share link (on the left hand side) and test it
Re: Save Games Help
Posted: Sat May 22, 2021 5:42 pm
by Darigaaz
I think you need to do this to have your value at to 0 the first time the user plays
var value1 = teaseStorage.getItem('value1A') || 0;
Re: Save Games Help
Posted: Sun May 23, 2021 9:24 am
by intermolecularpyro
Awesome, it seems to work fine.
Thank you both for your help!