Save Games Help

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
intermolecularpyro
Explorer
Explorer
Posts: 51
Joined: Wed Jan 15, 2020 8:19 am

Save Games Help

Post 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!
User avatar
Shattered
Experimentor
Experimentor
Posts: 1392
Joined: Fri Jan 11, 2013 6:41 pm
I am a: Switch
Location: United Kingdom

Re: Save Games Help

Post 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!
intermolecularpyro
Explorer
Explorer
Posts: 51
Joined: Wed Jan 15, 2020 8:19 am

Re: Save Games Help

Post 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!
User avatar
Shattered
Experimentor
Experimentor
Posts: 1392
Joined: Fri Jan 11, 2013 6:41 pm
I am a: Switch
Location: United Kingdom

Re: Save Games Help

Post 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)
intermolecularpyro
Explorer
Explorer
Posts: 51
Joined: Wed Jan 15, 2020 8:19 am

Re: Save Games Help

Post 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!
User avatar
Shattered
Experimentor
Experimentor
Posts: 1392
Joined: Fri Jan 11, 2013 6:41 pm
I am a: Switch
Location: United Kingdom

Re: Save Games Help

Post 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
Darigaaz
Explorer
Explorer
Posts: 88
Joined: Wed Oct 07, 2020 11:12 pm
Gender: Male
Sexual Orientation: Straight

Re: Save Games Help

Post 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;
intermolecularpyro
Explorer
Explorer
Posts: 51
Joined: Wed Jan 15, 2020 8:19 am

Re: Save Games Help

Post by intermolecularpyro »

Awesome, it seems to work fine.

Thank you both for your help!
Post Reply