Super Easy Checkpoint Saving [Updated]

'cuz I literally (was) have no idea with what is causing your error, and I chose to step away and hide at the dark corner of the room instead of giving any feedback :sob:


@Nonvita
After a careful, thorough perusal, I figured out that indeed [save_save_morebananasb] shouldnā€™t exist.
Instead, the one that should exist on its place (which is [save_num2]) should be [save_morebananasb].

IDK. You get that error when going to the #Go back. at check_2, isnā€™t it? :thinking:


Edit: Iā€™ve tried to reproduce with the bug and come up with followingā€¦ report.
BTW, this is my code.

Code

*label first
Allright. This is just a blurb. Letā€™s begin saving
*choice
#Save
*set save_num ā€œcheck1ā€
*set save_check1 ā€œ~hp~hp_lim~str~agi~foc~flakeā€
*gosub_scene twiger_functions save

	*goto back
#Return to main menu
	*goto_scene startup

*label back
Youā€™re done saving. Letā€™s alter some stats
*set hp 100
*set hp_lim ā€œhaha no wayā€
*set flake ā€œ-5ā€

BTW, it was HP +100, max hp ā€œhaha no way,ā€ and flake -5.

Now, letā€™s load
*fake_choice
#Load
*set save_num ā€œcheck1ā€
*gosub_scene twiger_functions load

Boom! Itā€™s done. Check the stats screen.
*page_break Finish
*goto first

My conclusion is

  1. The error is produced when you go into save > load > save > LOAD.
    There. The second time you load a same save, the error occurs.
  2. I believe it has something with ā€œrefreshingā€ your variables.
    Iā€™m not sure if this is the case, but I think this is the culprit :point_down:t4:
166 *temp save_num2 save_num
167 *set save_num ("save_" & save_num) <<<<<
168 *set save_num2 ("save_" & (save_num2 & "b"))

Iā€™ve tried to load a save twice and always encounter the bug, although the report are different from @Nonvitaā€™s.

twiger_functions line 240: Non-existent variable ''

2 Likes

Could it be because *temp is used again instead of using *set ?

50,000 Twiger points to whoever finds the solution first.

1 Like

I figured out that the problem with your code is that youā€™re lacking *set save_num "morebananas"
I mean, put it like this

*choice
	#Finish.
		You have ${bananas} banana@{bananas |s|s}. No more bananas for you!
		*finish
	#Go back.
        *set save_num "morebananas"   <<<<<<<<<<<<---
		*gosub_scene twiger_functions load
		*goto check_2

I think you still need to *set the [save_num] no matter what kind of process youā€™re going to get through (load/save), which isnā€™t a big deal by itself.


Well then, back to my own code. :eyeglasses:



@Twiger_Fluff Nah, Iā€™ve done an experiment using *temp and *set before, and itā€™s unlikely that the cause is the *temp.
Both of them works quite similar, it just that *temp got deleted whenever the subroutine is done.


Edit:
I think I have a question that can narrow us down the problem.

So, we have label load4
*set holder saves_string

and load7
*set {holder} saves_string

Any reason why the 7 has curly parentheses why the 4 is not?

Iā€™ve tried put the 4 on a parentheses, and the error occurrence shifts up exactly on that line.
While removing all the parentheses makes your loading function do nothing.

2 Likes

Except, alas, their game design philosophy. See the ā€œback buttonā€ question on the FAQ.

I can imagine that they might let it go through in a Hosted Game, but unless thereā€™s been some reason for them to reconsider their lack of a back button, I doubt itā€™ll ever make it to an official CoG title.

Edit ā€“ whoops, sorry, I realize I was responding more to IvoryOwlā€™s

and your response

rather than what your current code actually does. :slight_smile:

3 Likes

Yes, that was my thought as well. Obviously they have the capabilities to produce some sort of ā€œbackā€ button / checkpoint system, but they donā€™t. I can understand their reasoning, but I do find myself wishing all too often for oneā€¦ (Not to avoid failure, mind you, but it happens fairly regularly that the outcome of a choice is completely unexpected for me, and isnā€™t something that fits with my MCā€™s characterization.)


@Szaal Tried itā€”you were right! You have to set save_num both for saving and loading. I also had to shift my code a little so I set the variables after doing the checkpoint save (duh!) but it works now!
:banana::banana::banana: Semua pisang buat Mas :banana::banana::banana:

Is thatā€¦ That ringing noiseā€¦ Do I hearā€¦

2 Likes
All's cool here (kinda)

Okay, youā€™ll hate this. I spent like 4 hours today driving to my grandparentā€™s and another 4 back so I couldnā€™t really work on it today but while I was in the pool it took me three second of thinking over what you said in your last post and I found the solution/problem (hopefully)

long story short:

But in the function it takes save_num and changes it.

end of long/short story. Iā€™ll have to test using a new *temp instead of save_num so it doesnā€™t get changed but I think thatā€™s it.


@Szaal That did it! Whoo. Go swimming! Iā€™ve updated the link with the fixed version of twiger_functions (now you can go back to setting the save_num only once). But as Iā€™m testing @Nonvitaā€™s banana thing I get the error bananas line 20: invalid @{} at letter 49; ā€˜bananasā€™ is equal to 4 but there are only 3 options
You probably need to check if bananas is above 3 and then end the thing before doing the @{} thing.
Someone needs to explain to me what in the world banana@{bananas |s|s} is/does Iā€™ve never seen @{} or |s|s

Edit: Iā€™m look at the annoncement that explains it here. I kinda understand it but Iā€™m still really confused on the syntax.


Changing the code to this:

2018 Best Seller "Bananas"

*label check_1
*set bananas +1
*set save_num ā€œbananasā€
*set save_bananas ā€œ~bananasā€
*gosub_scene twiger_functions save
*if (bananas < 4)
This is checkpoint 1. You have ${bananas} banana@{bananas |s|s}.

*choice
#Continue.
*goto check_2
#Start over.
*gosub_scene twiger_functions load
*goto check_1

*label check_2
*set bananas +2
*set save_num ā€œmorebananasā€
*set save_morebananas ā€œ~bananasā€
*gosub_scene twiger_functions save
*if (bananas < 4)
This is checkpoint 2. You have ${bananas} banana@{bananas |s|s}.

*choice
#Finish.
*if (bananas < 4)
You have ${bananas} banana@{bananas |s|s}. No more bananas for you!
*finish
#Go back.
*gosub_scene twiger_functions load
*goto check_2
#Start over.
*set save_num ā€œbananasā€
*gosub_scene twiger_functions load
*goto check_1

I get the error twiger_functions line 243: Non-existent variable ā€˜ā€™
So Iā€™m back to T_F being goofed.

*set {holder} saves_string is now line 243 which is the one causing the error above so maybe itā€™s not so perfect.

Welllllll taking out the {} on L243 fixes the error and randomtest passes. (quicktest doesnā€™t tho. Man I hate quicktest sooo much) HOWEVER the load function stops working.
note: Deleting line 243 (the *set holder after label load7) doesnā€™t seem to really change anything)

Explanation of why 4 and 7 are different

4 sets holder to the variables name, then by the time 7 happens, 7=the variableā€™s value. #7 sets the variable in the list to itā€™s original value which is why 7 must have {} so there must be another solution to the error Iā€™m getting.

haaalllpppp please

@Szaal I think it might have something to do with this:

*if (letter = "") or (letter = "~")
 *goto load4
*else
 *set saves_string (saves_string & letter)
 *goto load3

That might make it so the saves_string (which holder is set to) never gets a value past the initial value of ā€œā€
So I added this:

*if holder != ""
 *set {holder} saves_string

But that seems to bring up the problem of the load function not doing anything. Iā€™m still just testing the bananas thing so maybe itā€™s just that? maybe at least two variables need to be used in the save.

@Szaal @Nonvita
You can probably just ignore that whole post above.
The long and short is I think @Nonvita was doing something wrong, like 99.9999999% sure because now that I think about it, NONE of the text appeared after starting over. And v7 of twiger_functions works 100% perfecto on my own saving tests.

1 Like

Yes I said before I had to move the *set lines after the save code.

Now that thatā€™s fixed I get the error you mentioned:
line 240 of twiger_functions: Non-existent variable "

2 Likes

Sooā€¦ everything is cool, here?
:eyes:

1 Like

@Szaal More me and my code it is, but it seems @Nonvita needs help still.
The stuff I use to test the save system:

startup.txt
*create a "alpha"
*create beta "b"
*create c "charlie"
*create delta "d"
*create e "echo"
*comment up is mysave down is uniform
*create foxtrot "f"
*create g "golf"
*create hotel "h"
*create i "indigo"
*create save_num ""
*create save_mysave "~a~delta~beta~c~e"
*create save_mysaveb ""
*create save_uniform "~g~foxtrot~i~hotel"
*create save_uniformb ""

*set save_num "mysave"
*gosub_scene twiger_functions save

mysave is ${a} ${beta} ${c} ${delta} ${e}
*line_break
*set save_num "uniform"
*gosub_scene twiger_functions save
uniform is ${foxtrot} ${g} ${hotel} ${i}

They are now both saved.

Randomnizing variables...
*rand a 0 100
*rand beta 0 100
*rand c 0 100
*rand delta 0 100
*rand e 0 100
*rand foxtrot 0 100
*rand g 0 100
*rand hotel 0 100
*rand i 0 100


mysave is now ${a} ${beta} ${c} ${delta} ${e}
*line_break
uniform is now ${foxtrot} ${g} ${hotel} ${i}

Too bad. I don't like that. I want them to go back so...
Loading saves...
*gosub_scene twiger_functions load
*set save_num "mysave"
*gosub_scene twiger_functions load

now they're back:

mysave is ${a} ${beta} ${c} ${delta} ${e}
*line_break
uniform is ${foxtrot} ${g} ${hotel} ${i}

but changed again
*rand a 0 100
*rand beta 0 100
*rand c 0 100
*rand delta 0 100
*rand e 0 100
*rand foxtrot 0 100
*rand g 0 100
*rand hotel 0 100
*rand i 0 100

mysave is now ${a} ${beta} ${c} ${delta} ${e}
*line_break
uniform is now ${foxtrot} ${g} ${hotel} ${i}

we'll load uniform again:
*set save_num "uniform"
*gosub_scene twiger_functions load

uniform is now ${foxtrot} ${g} ${hotel} ${i}

save it again:
*gosub_scene twiger_functions save

and load it again:
*gosub_scene twiger_functions load

uniform is now ${foxtrot} ${g} ${hotel} ${i}

*finish
The output (as tested in MyGame/index.htm)
mysave is alpha b charlie d echo
uniform is f golf h indigo

They are now both saved.

Randomnizing variables...

mysave is now 79 30 21 26 60
uniform is now 94 86 15 63

Too bad. I don't like that. I want them to go back so... Loading saves...

now they're back:

mysave is alpha b charlie d echo
uniform is f golf h indigo

but changed again

mysave is now 59 35 50 0 23
uniform is now 60 10 52 47

we'll load uniform again:

uniform is now f golf h indigo

save it again:

and load it again:

uniform is now f golf h indigo

Mine works, itā€™s only if I go back to the checkpoints several times it gets the error.

This is my code.
*create save_num ""
*create save_bananas ""
*create save_bananasb ""
*create save_morebananas ""
*create save_morebananasb ""
*create bananas 0

*label check_1
*set save_num "bananas"
*set save_bananas "~bananas"
*gosub_scene twiger_functions save
*set bananas +1
This is checkpoint 1. You have ${bananas} banana@{bananas |s|s}.

*choice
	#Continue.
		*goto check_2
	#Start over.
		*set save_num "bananas"
		*gosub_scene twiger_functions load
		*goto check_1

*label check_2
*set save_num "morebananas"
*set save_morebananas "~bananas"
*gosub_scene twiger_functions save
*set bananas +2
This is checkpoint 2. You have ${bananas} banana@{bananas |s|s}.

*choice
	#Finish.
		You have ${bananas} banana@{bananas |s|s}. No more bananas for you!
		*finish
	#Go back.
		*set save_num "morebananas"
		*gosub_scene twiger_functions load
		*goto check_2
	#Start over.
		*set save_num "bananas"
		*gosub_scene twiger_functions load
		*goto check_1

Feel free to try it out. If you continue, then go back and forth several times it pops up the error. Thatā€™s the only time.

Well, I hope that thereā€™s no one attempting to load their save multiple times :sweat_smile:

2 Likes

@Szaal @Nonvita To clarify, I see absolutely no problem with loading the same save a hundred times with or without setting the save_num again (make sure youā€™re using twiger_function v0.7 as opposed to v6 as named in the first few lines)
Here is why Iā€™m pretty sure that loading can be done all you want:




Youā€™re welcome for including my personal problems.

The Code

`mysave is {a} {beta} {c} {delta} {e} *line_break uniform is {foxtrot} {g} {hotel} ${i}

but changed again
*rand a 0 100
*rand beta 0 100
*rand c 0 100
*rand delta 0 100
*rand e 0 100
*rand foxtrot 0 100
*rand g 0 100
*rand hotel 0 100
*rand i 0 100

mysave is now {a} {beta} {c} {delta} {e} *line_break uniform is now {foxtrot} {g} {hotel} ${i}

weā€™ll load uniform again:
*set save_num ā€œuniformā€
*gosub_scene twiger_functions load

uniform is now {foxtrot} {g} {hotel} {i}

save it again:
*gosub_scene twiger_functions save

and load it again:
*gosub_scene twiger_functions load

uniform is now {foxtrot} {g} {hotel} {i}

and mess it up

*set foxtrot ā€œJane is cute.ā€
*set g ā€œJane is my friend.ā€
*set hotel ā€œJane is bi,ā€
*set i " but not into me :("
uniform is now {foxtrot} {g} {hotel} {i}

and load it again:
*gosub_scene twiger_functions load

uniform is now {foxtrot} {g} {hotel} {i}

and mess it up

*set foxtrot ā€œJane is cute.ā€
*set g ā€œJane is my friend.ā€
*set hotel ā€œJane is bi,ā€
*set i " but not into me :("
uniform is now {foxtrot} {g} {hotel} {i}

and load it again:
*gosub_scene twiger_functions load

uniform is now {foxtrot} {g} {hotel} {i}

and mess it up

*set foxtrot ā€œJane is cute.ā€
*set g ā€œJane is my friend.ā€
*set hotel ā€œJane is bi,ā€
*set i " but not into me :("
uniform is now {foxtrot} {g} {hotel} {i}

and load it again:
*gosub_scene twiger_functions load

uniform is now {foxtrot} {g} {hotel} {i}

and mess it up

*set foxtrot ā€œJane is cute.ā€
*set g ā€œJane is my friend.ā€
*set hotel ā€œJane is bi,ā€
*set i " but not into me :("
uniform is now {foxtrot} {g} {hotel} {i}`

Iā€™m sure it can load multiple times. The code itself works mostly great. Like I said it just sometimes returns that error. You can try out the code I pasted for yourself. Iā€™m not trying to say the code is bad, Iā€™m just reporting what I find. What I found is if I loaded several times it popped up an error. All Iā€™m suggesting is maybe looking into the error a bitā€”thatā€™s what coders/designers do, they fix bugs that pop up, not just deny that they exist.

No, people shouldnā€™t be reloading all the time. But when thereā€™s a bug, it means the potential for a problem during someoneā€™s play.

1 Like

8:02am Alright, Iā€™ll test your code for a few theories I have. The only thing that really makes your bananas testing different from my testing is you only use one variable which is pretty pointless so if it turns out that you need to have at least two (my working theory) then oh well: no need to support saving only one variable since a *temp for it would be better than two saves variables. If itā€™s not that, Iā€™m stumped for the time being.


8:12am Iā€™m not getting any errors, however when I try to go back from checkpoint 2, it doesnā€™t change anything. No errors. No missing text. @Nonvita Do you know what order of buttons you press to get an error/problem?

1 Like

Just clicking around between Continue, Go Back, and Start Over. Iā€™ll try adding more variables (yeah, itā€™s totally pointless with just one) and see if it still pops up. Anyway, I should probably just change my code around a bit and try out some different code with it. But my brainā€™s been a little tooā€¦bananasā€¦recently, sorry.

1 Like