Hi all,
Big favor to ask.
I am trying to add saves to my tease and failing miserably. If any of you have the time and expertise, would you be so kind as to look at my effort and tell me how to fix whatever is going wrong.
My save strategy is:
CHECKPOINTS
- Create a dozen or so checkpoints. At each checkpoint, save all variables. This seems to be failing spectacularly. I'm sure I've messed up the phrasing, but I'm not sure how. Current format of those EVAL commands:
MC NAME: teaseStorage.setItem('yourname',yourname)
SAMPLE VARIABLE: teaseStorage.setItem('bi',bi)
Assign a value "checkpoint" which saves the location. This seems to work? It doesn't crash. But it doesn't work for the jump. See below:
checkpoint="morning1"
morning1 is the name of the page of the first checkpoint.
START
- On open, load all variables, starting with a counter that tells the player how many times they've played and the player's MC name. The counter seems to be working. The MC name doesn't.
COUNTER: var counter = teaseStorage.getItem("counter") ||0
MC NAME: yourname=teaseStorage.getItem('yourname')
- Load all other variables. I can't tell if this is working or not.
TYPICAL VARIABLES:
bi=teaseStorage.getItem('bi')
sub=teaseStorage.getItem('sub')
ass=teaseStorage.getItem('ass')
- Allow returning player to jump to their last saved checkpoint. Doesn't work. Freezes game. Command I'm using is:
pages.goto('checkpoint')
Can anyone tell me what I'm doing wrong? If you want to look at the entire tease:
https://milovana.com/webteases/showteas ... fe3c5d1f3a
Thanks in advance!
Need help with saves!
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
-
Thamrill
- Explorer At Heart

- Posts: 301
- Joined: Thu Jan 03, 2013 4:55 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: Submissive
Re: Need help with saves!
One thing I noticed is that you save the counter way before the user enter their name. Hence if you restart the tease before the name is saved, it will default to the undefined name. I will look more into details tomorrow
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
Re: Need help with saves!
Fixed that, thanks.
There's definitely a problem with how I'm writing out the set and get functions, since those both cause things to fail when I run them in test.
There's definitely a problem with how I'm writing out the set and get functions, since those both cause things to fail when I run them in test.
Re: Need help with saves!
Isn't that trying to open a page named checkpoint? While a
pages.goto(checkpoint)
might be what you're looking for?
You have a "default 0" for your counter (that ||0), but not the other variables (you may have skipped mentioning them of course). But if your inits are not spot on, you might not have numbers to load, especially on a first run of a user. That leads to nulls, which need special treatment.
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
Re: Need help with saves!
I'll try that. Thanks. Can it just be (checkpoint) if checkpoint is a defined variable? Or does it need to be (var checkpoint) or something?spaisin wrote: Wed Aug 10, 2022 11:38 pmIsn't that trying to open a page named checkpoint? While a
pages.goto(checkpoint)
might be what you're looking for?
I'll add that to all numeric variables. Does the rest of the format for the set and gets look right?You have a "default 0" for your counter (that ||0), but not the other variables (you may have skipped mentioning them of course). But if your inits are not spot on, you might not have numbers to load, especially on a first run of a user. That leads to nulls, which need special treatment.
Also, if the variable is not numeric, like the name variable for example, do I still do ||0 or do I need to do ||null or ||"null" or something?
Also do I just as the ||0 to the gets? Or to the sets as well.
I really am hopeless with this stuff.
Thank you!
-
Thamrill
- Explorer At Heart

- Posts: 301
- Joined: Thu Jan 03, 2013 4:55 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: Submissive
Re: Need help with saves!
If you already defined in the init the variable checkpoint, you just use checkpoint:ritewriter wrote: Thu Aug 11, 2022 12:37 am I'll try that. Thanks. Can it just be (checkpoint) if checkpoint is a defined variable? Or does it need to be (var checkpoint) or something?
checkpoint=teaseStorage.getItem('checkpoint')
pages.goto(checkpoint)
It's not exactly super safe, but since they are loading the variable only after the first run (where all variables ought be set), the only variable that needs a default is the one counting runs.ritewriter wrote: Thu Aug 11, 2022 12:37 amYou have a "default 0" for your counter (that ||0), but not the other variables (you may have skipped mentioning them of course). But if your inits are not spot on, you might not have numbers to load, especially on a first run of a user. That leads to nulls, which need special treatment.
Only to get, as you are saying get the variable from the storage; if it is absent, set value to this. And it should be the same type of the original variable, so for example:ritewriter wrote: Thu Aug 11, 2022 12:37 am Also, if the variable is not numeric, like the name variable for example, do I still do ||0 or do I need to do ||null or ||"null" or something?
Also do I just as the ||0 to the gets? Or to the sets as well.
yourName=teaseStorage.getItem('yourName')||'Default name';
where you put a specific name in place of Default name, which is better, in case of error, than seeing undefined or null.
I'd suggest you to take a brief introductory course in javascript (there're tutorials on youtube), if you struggle with the fundamentals of EOS scripting. You can't find infos about the specific features of EOS (teaseStorage etc.), but you can understand better variables etc.
Also, I suggest you create a smaller tease where you can test and practice, before adding these modification to your bigger tease
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
Re: Need help with saves!
Thank you. I'll do that.Thamrill wrote: Thu Aug 11, 2022 7:54 am
I'd suggest you to take a brief introductory course in javascript (there're tutorials on youtube), if you struggle with the fundamentals of EOS scripting. You can't find infos about the specific features of EOS (teaseStorage etc.), but you can understand better variables etc.
Also, I suggest you create a smaller tease where you can test and practice, before adding these modification to your bigger tease
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
Re: Need help with saves!
Still struggling with saves unfortunately.
I created a test tease. It's here:
https://milovana.com/webteases/showteas ... 4a7d33bec7
Storing and retrieving simple variable seems to be working fine.
Storing and retrieving string variables like 'yourname' is also working.
The only thing that's NOT working is the
pages.goto('checkpoint') command.
I've tried
pages.goto(checkpoint)
pages.goto('checkpoint')
pages.goto("checkpoint")
None of these work. I can do a work-around with IF/THEN if necessary, but it would be much easier if I could make pages.goto work.
Let me know if anyone has any suggestions. Thanks!
I created a test tease. It's here:
https://milovana.com/webteases/showteas ... 4a7d33bec7
Storing and retrieving simple variable seems to be working fine.
Storing and retrieving string variables like 'yourname' is also working.
The only thing that's NOT working is the
pages.goto('checkpoint') command.
I've tried
pages.goto(checkpoint)
pages.goto('checkpoint')
pages.goto("checkpoint")
None of these work. I can do a work-around with IF/THEN if necessary, but it would be much easier if I could make pages.goto work.
Let me know if anyone has any suggestions. Thanks!
Re: Need help with saves!
Oh JS, how I love to hate you...
pages.goto("2")
works, goes to a page named 2
pages.goto(2)
doesn't work, just silently doesn't do anything
pages.goto(checkpoint)
when the checkpoint contains a number, it behaves like number, because of course
when it contains a string, it'll behave like a string
So, you can typecast your number into a string and it should work
pages.goto(String(checkpoint))
It did in my test...
And / or, you can give your pages string-names and the issue goes into a hiding-mode...
pages.goto("2")
works, goes to a page named 2
pages.goto(2)
doesn't work, just silently doesn't do anything
pages.goto(checkpoint)
when the checkpoint contains a number, it behaves like number, because of course
when it contains a string, it'll behave like a string
So, you can typecast your number into a string and it should work
pages.goto(String(checkpoint))
It did in my test...
And / or, you can give your pages string-names and the issue goes into a hiding-mode...
- ritewriter
- Explorer At Heart

- Posts: 454
- Joined: Sun Jan 02, 2022 6:51 am
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Switch
Re: Need help with saves!
That worked! Thank you!spaisin wrote: Sat Aug 13, 2022 7:33 pm
So, you can typecast your number into a string and it should work
pages.goto(String(checkpoint))
It did in my test...
And / or, you can give your pages string-names and the issue goes into a hiding-mode...![]()
Re: Need help with saves!
Great
The power of shared "test code"; I wouldn't have guessed the issue from your text description, but seeing and testing the code made it pretty easy to spot.
