ChoiceScript Saving Plugin (Update: April 2023)

Currently using Firefox 17.0.1

I had originally neglected to update my Firefox, but even after doing so I canā€™t replicate the issue.

Some options:

  • Make sure save.js is the last script you include in index.html
  • Redownload save.js (you may have got a very unlucky 10s gap version where I noticed a typo or something).
  • Try another browser
  • Post the firefox j/s console errors (if that means anything to you)

In the j/s console iā€™m getting a ā€œTypeError: Button is undefinedā€ on line 95 of the ā€œsave.jsā€ file.

The problem seems to be in this area in save.js

function toggleAutosave(autosavebutton) {
if (saveMod.autoSave == false) {
button.innerHTML = ā€œDisable Autosaveā€;
saveMod.autoSave = true;
alert(ā€œAutosave Enabled!ā€);
return;
}
else {
button.innerHTML = ā€œEnable Autosaveā€;
saveMod.autoSave = false;
alert(ā€œAutosave Disabled!ā€);
return;
}
alert(ā€œtoggleAutosave Error - Please inform the game developer!ā€);
}

if I change the button.innerHTML to self.innerHTML it seems to work but the text inside the buttons does not change anymore.

Iā€™m almost certain that youā€™ve managed to get a dodgy file there, try redownloading save.js and replacing your current one. Iā€™m 99% sure this will sort it, let me know if it doesnā€™t though.

EDIT: Yes, thatā€™s an old file. Either redownload save.js or replace (autosavebutton) with (button).
Iā€™d recommend the former as there may be other hidden issues with that version.

Donā€™t change it to self.

I tried re-downloading it and still experienced the same problem, iā€™ve altered the file using my (admittedly minimal) knowledge of JS and it now seems to be working.

Iā€™ve put the amended file here

http://www.4shared.com/document/A7hL_lxq/save.html

incase you fancy a look CJW?

1 Like

I donā€™t have a 4shared account, donā€™t really want one either and you canā€™t seem to download it without one.

Iā€™d love to take a look though, is there anywhere else you can upload it, dropbox, webs, mediafire or something?

Pastebin is very good too (just copy/paste, give link).

1 Like

Please find below the public link to a sample game using the amended JS code that I am currently using for autosave in my game

http://dl.dropbox.com/u/129688634/sample%20autosave%20game/mygame/index.html

please note that I have disabled the messages for ā€œenableā€ and ā€œdisableā€ autosave deliberately because I donā€™t intend to have them in the finished game that I am working on.

And here is a dropbox link to the amended save.js file that I am using currentlyā€¦
http://dl.dropbox.com/u/129688634/sample%20autosave%20game/save.js

1 Like

It would have been easier to just replace autosavebutton with button rather than all those other buttons with autosavebutton, but Iā€™m glad you got it working.
Sorry about the bork!

1 Like

No worries, itā€™s a very useful system (and is helping speed up my testing of my current planned game no end) - also itā€™s helping me to slowly learn a bit about javascript so itā€™s all good :slight_smile:

Iā€™ve trimmed it down a bit to use ā€œbuttonā€ rather than ā€œautosavebuttonā€ as described and is all working fine - thanks very much for the advice :slight_smile:

1 Like

Thank you very much for reporting that, after a closer look at my files I discovered the problem.
There are different code blocks that fire depending on your browser and whether your playing locally or online, in the local block Iā€™d neglected to pass the button as a parameter, hence the error.

I didnā€™t pick up on it as I was using the dropbox (online) hosted version to test it.

Dā€™oh! Seems extremely appropriate right about now :stuck_out_tongue:

Iā€™ve fixed it anyway, thanks again - thereā€™s no telling how long something that obscure might have continued to go on unnoticed!


If anyone has downloaded the enable/disable update before this post, please re-download it!

1 Like

@CJW

One thing Iā€™ve learnt is that if you get an error and choose to load the game you get a different error message. But you only have to fix the first error to sort both out.

1 Like

Iā€™m not entirely sure what you mean?

1 Like

I think that @Nocturnal_Stillness means that, if you encounter a game stopping error and then attempt to load a saved game, it produces a different error message (presumably because it is trying to continue the same scene?); I have found that if you just load it again after that then the load function rolls the game back to slightly earlier and is normally error free.

1 Like

When I was testing I got an error about indentation so I clicked the load button to reload the last save and I got an error talking about a missing choice. The line mentioned had no choice but once I fixed the indentation error the choice error didnā€™t reappear.

1 Like

@Largejo @Nocturnal_Stillness Ah, well the system saves every page - so naturally if you get an error on a page and then try to reload (said page), it is going to break, no question about itā€¦ Sadly thereā€™s not a lot I can do about that :confused:

Iā€™m interested in your situation though Largejo, Iā€™d expect it to behave more like with Nocturnal_Stillness.

It might be that errors are thrown by choicescript before the save is made, depends on the order of function call?

1 Like

LOL mine isnā€™t a situation so much since it works great for me whilst tested my WIP game; the way mine seems to work is that, if I have 2 scenes for example (scene1 and scene2) that follow on from each other and scene2 has a game stopping error, when I load the first time it will reshow the error, if I reload it again then this time the save game will roll back to scene1.

This isnā€™t a problem for me, quite the contrary, it works very well and is allowing me to test sections of the game without having to play right through from the start everytime :slight_smile:

1 Like

Thatā€™s cool if admittedly unintentional functionality ^^

It might be because youā€™re using the enable/disable toggle version, whereas Nocturnal_Stillness is not.

1 Like

@CJW

I didnā€™t think you could sort it as the save works fine. Just wanted to let you know as I spent a good hour trying to locate the second error yesterday before I realised what was causing it.

Are you still thinking about save slots?

1 Like

@Nocturnal_Stillness Yes, though how Iā€™d include them Iā€™m not sure.
I donā€™t really think 3*3 buttons is going to work very well, but to do anything more complicated like integrating it into the choice boxes requires a more complex installation or the overwriting of half the scene.js fileā€¦

Any ideas on that front?

Iā€™m happy to do it - Iā€™m just not sure how you guys would want to go about it.
I presume the simple installation/un-installation is something you want to retain.

1 Like