Multiple Stat Screens

I promise only off topic a litte, I was wonder is it possible to add a second stat button and have it only display a image like a map.

@lordirish
Eh! That’s what I want to include in ‘Legions of Rome’ too.

@mattnoles
Yes would be very cool, in my A Thiefs Apprentice I would like them to be able to pull a crude map, depending on which floor they are on, of the prision.

@lordirish
How would you change the image based on the level your located on?

@mattnoles ok now I have second question lol.

@lordirish
This is complicated but it may work.
For each level of your castle you have the command *set level 1 (it doesn’t have to be number one but it will work for my example) Be sure to have this command included right at the beginning of the new level so the image should update itself.

Then when you go to the next level it would have *set level 2 in the beginning of the scene. You would obviously have to defined the variable level in the mygame.js but just make it hidden and don’t write it into the choicescript_stats.txt

Then utilizing the *if & *ifelse and the *image command we can now set up the second “map” tab shall we call it.

So I am imagining the tab to look something like this:

*if scene = 1
–*image (map-of-level-one-filename).jpg
*ifelse scene = 2
–*image (filename).jpg

and so on and so on for each desired level of the castle.

In theory I suppose this should work.

@mattnoles
Thanks I’ll give it a try over the next few days. Need to flesh out the first section then add the maps and see if I can get it to work.

Ok well I got my second button programmed and working so I am going to give it a go now.

how do i edit the index file on my version? i am struggling to see how to edit the source on windows 7 although i can view it after right clicking the page and clicking ‘view source’. opening the file in notepad does not allow me to do what is mentioned here because i do not see the code i see in page source. please help!

EDIT: got it. sorry.

Download notepad++ anyway, it’ll make things a lot easier :slight_smile:

@CJW that was my fix! along with hitting f12 on ie (i know, i know. i just prefer ie for now). by the way, i noticed a problem with the js code @Reaperoa posted if it is just copied and pasted with the highlighed version edited.

if (window.confirm(“Restart your game? Did you click that intentionally?”)) {
document.getElementById(“statsButton1”).style.display = “inline”;

and

printButton(buttonName || “Next”, text, false, function() {
window.stats.scene = currentScene;
document.getElementById(“statsButton1”).style.display = “inline”;
clearScreen(loadAndRestoreGame);

here meant if the number referring to the button meant that the second button (in my case) would simply disappear when returning to the game. sorry this won’t format properly. i was unsure how to highlight code as above.

I have looked at this code so long my head hurts. Can someone else look at and tell me what I am missing please.
I have all three buttons showing but when I click on any one of them I get

Unable to get value of the property ‘style’; object is null or undefined.
Thanks for your help.

`
function showStats1() {
document.getElementById(“statsButton1”).style.display = “none”;
document.getElementById(“statsButton2”).style.display = “inline”;
document.getElementById(“statsButton3”).style.display = “inline”;
main.innerHTML = “

”;
var currentScene = window.stats.scene;

var scene = new Scene("stats_scene_1", window.stats, this.nav);
scene.save = function(callback) {if (callback) callback.call(scene);}; // Don't save state in stats screen, issue #70
// TODO ban *choice/*page_break/etc. in stats screen
scene.finish = scene.autofinish = function(buttonName) {
  this.finished = true;
  this.paragraph();
  var p = document.createElement("p");
  var restartLink = document.createElement("a");
  restartLink.setAttribute("style", "text-decoration: underline; cursor: pointer; text-align: left");
  restartLink.onclick = function() {
      if (window.confirm("Restart your game?  Did you click that intentionally?")) {
          document.getElementById("statsButton1").style.display = "inline";
          clearCookie(function() {
            window.nav.resetStats(window.stats);
            clearScreen(restoreGame);
          }, "");
      }
      return false;
  }
  restartLink.innerHTML = "Start Over from the Beginning";  
  p.appendChild(restartLink);
  var text = document.getElementById('text');
  text.appendChild(p);

  printButton(buttonName || "Next", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton1").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}

function showStats2() {
document.getElementById(“statsButton2”).style.display = “none”;
document.getElementById(“statsButton1”).style.display = “inline”;
document.getElementById(“statsButton3”).style.display = “inline”;
main.innerHTML = “

”;
var currentScene = window.stats.scene;

var scene = new Scene("stats_scene_2", window.stats, this.nav);
scene.save = function(callback) {if (callback) callback.call(scene);}; // Don't save state in stats screen, issue #70
// TODO ban *choice/*page_break/etc. in stats screen
scene.finish = scene.autofinish = function(buttonName) {
  this.finished = true;
  this.paragraph();
  var p = document.createElement("p");
  var restartLink = document.createElement("a");
  restartLink.setAttribute("style", "text-decoration: underline; cursor: pointer; text-align: left");
  restartLink.onclick = function() {
      if (window.confirm("Restart your game?  Did you click that intentionally?")) {
          document.getElementById("statsButton2").style.display = "inline";
          clearCookie(function() {
            window.nav.resetStats(window.stats);
            clearScreen(restoreGame);
          }, "");
      }
      return false;
  }
  restartLink.innerHTML = "Start Over from the Beginning";  
  p.appendChild(restartLink);
  var text = document.getElementById('text');
  text.appendChild(p);

  printButton(buttonName || "Next", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton2").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}

function showStats3() {
document.getElementById(“statsButton3”).style.display = “none”;
document.getElementById(“statsButton1”).style.display = “inline”;
document.getElementById(“statsButton2”).style.display = “inline”;
main.innerHTML = “

”;
var currentScene = window.stats.scene;

var scene = new Scene("stats_scene_3", window.stats, this.nav);
scene.save = function(callback) {if (callback) callback.call(scene);}; // Don't save state in stats screen, issue #70
// TODO ban *choice/*page_break/etc. in stats screen
scene.finish = scene.autofinish = function(buttonName) {
  this.finished = true;
  this.paragraph();
  var p = document.createElement("p");
  var restartLink = document.createElement("a");
  restartLink.setAttribute("style", "text-decoration: underline; cursor: pointer; text-align: left");
  restartLink.onclick = function() {
      if (window.confirm("Restart your game?  Did you click that intentionally?")) {
          document.getElementById("statsButton3").style.display = "inline";
          clearCookie(function() {
            window.nav.resetStats(window.stats);
            clearScreen(restoreGame);
          }, "");
      }
      return false;
  }
  restartLink.innerHTML = "Start Over from the Beginning";  
  p.appendChild(restartLink);
  var text = document.getElementById('text');
  text.appendChild(p);

  printButton(buttonName || "Next", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton3").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}
`

Your buttons should each have onClick=“showStats#()” and an id=“statsButton#”

Where the hash matches the button’s number.
You also need three scene text files:
stats_scene_#.txt

The “function” (javascript bits) should jave EXACTLY the same name as tgeir relevant button id

function showStats#()

That error is basically saying it can’t find something to hide/unhide (I think) so you’ll have an id or function named wrong.

The names are matched but will recheck and also the rest of the info on the buttons thanks.

No problem.

If you’re still having problems message me a link to the files and I can take a look for you. :slight_smile:

thanks :slight_smile:

I found it , seems I had two id="statsButton2 labels. Once I changes it they startes working. Now onto the next problem. Thanks for your help@CJW

Anytime :slight_smile:
Glad to see it sorted!

You and me both, this project has turned in to a monster, nonetheless I still think once all is said and done it’s going to be worth it. :smiley:

That’s the spirit!
I’ve had a lot of issues myself, if I can save anyone that same frustration, I’m more than happy to do so :slight_smile: