Adding additional stat screens using latest version of Choicescript

Hello,

I have just downloaded the latest version of choicescript, and by copying the following code

function showStats() {
if (window.stats.sceneName == “choicescript_stats”) {
window.stats.scene = window.stats.scene.originalScene;
clearScreen(loadAndRestoreGame);
return;
}
var currentScene = window.stats.scene;
var scene = new Scene(“choicescript_stats”, window.stats, this.nav);
scene.originalScene = currentScene;
main.innerHTML = “

”;
scene.execute();
}

and amending it slightly, I have created a “credits” button on the main scene, by adding some additional lines to the printFooter function in ui.js I have also got it so that the credit button changes to say “Return to the game” in the same manner as the show stats button.

However when I got into my credit screen, instead of showing a next button at the bottom it shows the options normally printed at the end of a choicescript game - is there a way to prevent it from doing this and just have it show the next button?

Cheers :slight_smile:

It’s alright - I found it, you have to go into the scene.js file and locate this code

Scene.prototype.finish = function finish(buttonName) {
this.paragraph();
this.finished = true;
var self = this;
if (this.name == “choicescript_stats” && this.originalScene) {
printButton(buttonName || “Next”, main, false,
function() {
window.stats.scene = self.originalScene;
clearScreen(loadAndRestoreGame);
}
);
return;
}

…and then replicate the following, changing the name to the name of your new stat screen (as shown)…

if (this.name == "credit_stats" && this.originalScene) {
  printButton(buttonName || "Next", main, false, 
    function() { 
      window.stats.scene = self.originalScene;
      clearScreen(loadAndRestoreGame);
    }
  );
  return;
}

… can a mod please close this thread?

And you don’t need to copy the entire second function merely editing the first line -

if(this.name == “credit_stats” && this.originalScene || “choicescript_stats” && this.originalScene)

  • should suffice.

|| means ‘OR’ in JavaScript and && means ‘AND’.

Cheers @CJW :slight_smile: