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