Multiple Stat Screens & The Latest Version of Choicescript

I’ve implemented this after updating to the latest version of ChoiceScript, and I have to say, it’s been a big help, especially since I have so much reference material to organize.

One question though: When you click on a button and move to the corresponding stats screen, then click it again, it moves back to the scene where you were before.

Is there a way to make the button not do that?

@Cataphrak In ui.js function showStats(scene)


     if (window.stats.sceneName == scene) { //Is the button pressed the current scene's button?

Change that line to:


     if (window.stats.sceneName == "choicescript_stats") { //Is the button pressed the main stats screen/can we return to game?

That will make it so clicking the first button WHILE on the first page will return to the game, but clicking buttons 2 and 3 won’t do anything except move to that page - it won’t close them if you click it again while on that page.

Hmm, that’s not *quite* what I wanted.

Basically, I’m looking for a method to make it so that if I click my stats screen button in the main game to enter the stats screen, then click the stats screen button again while in the stats screen, I’ll remain in the stats screen, instead of returning to the ingame scene I had entered the stats screen from.

It might be less confusing if I just said I wanted a particular menu button’s function disabled while I was on the corresponding page.

EDIT: Wait, I just commented out that section governing bit of functionality. That won’t come to bite me in the ass later, will it?

Well commenting that out will effectively leave you stuck in the stats screen for all eternity, so maybe :smiley:

Scratch that, I forgot about the next buttons - You should be fine!

I’m guessing it’s a problem if, when you start your index, it’s loading infinitely? My guess: I did something wrong. It also says, before I allow it, that internet explorer has restricted this page from running scripts or ActiveX controls. Then…yeah, infinity loading. Oh, and where you had ‘choicescript_stats 2’ I have ‘choicescript_stats King Relations’ because of the name I gave the file. Also, when we edited FootPrinter (don’t know what to call it), I was on line 165, not 168.

So, any thoughts on the problem at hand (and, preferably, how to fix it)?

There’s quite a lot you *could* be doing wrong, looking at the top of IE and allowing scripts and ActiveX to run would be a good start!

Copy and paste your code between `


` tags, and I’ll take a look.

@CJW Alright, thanks. Also, what is IE? I’ve already allowed scripts and ActiveX to run.

<p><button id="statsButton" class="spacedLink" onclick="showStats('choicescript_stats')">Show Stats</button> <button id="statsButton" class="spacedLink" onclick="showStats('choicescript_stats King Relations')">Show Stats 2</button>  <button id="restartButton" onclick="restartGame('prompt')">Restart</button></p>

All of that is line 79.

function showStats(scene) {
    if (window.stats.sceneName == "choicescript_stats") {
     if (window.stats.sceneName == scene) { //Is the button pressed the current scene's button?
      window.stats.scene = window.stats.scene.originalScene; //If it is, return to game.
	  clear Screen (loadAndRestoreGame) ;
      return;
	   }
    }
	//Else, in any other case: Load selected stat screen.
    var currentScene = window.stats.scene;
    var scene = new Scene(scene, window.stats, this.nav);
    scene.originalScene = currentScene;
    main.innerHTML = "<div id='text'></div>";
    scene.execute();
}

Lines 54 to 68.

function printFooter() {
  // var footer = document.getElementById('footer');
  // We could put anything we want in the footer here, but perhaps we should avoid it.
 /* var statsButton = document.getElementById("statsButton");
  if (statsButton) {
    if (window.stats.sceneName == "choicescript_stats") {
      statsButton.innerHTML = "Return to the Game";
    } else {
      statsButton.innerHTML = "Show Stats";
    }
  } */
  setTimeout(function() {callIos("curl");}, 0);
}

Lines 176 to 188

// *finish
// halt the scene
Scene.prototype.finish = function finish(buttonName) {
    this.paragraph();
    this.finished = true;
    var self = this;
    if (this.name == "choicescript_stats" && this.originalScene) || "choicescript_stats King Relations" && this.originalScene) {
      printButton(buttonName || "Next", main, false,
        function() {
          window.stats.scene = self.originalScene;
          clearScreen(loadAndRestoreGame);
        }

Lines 526 to 537

Thanks again!

(Note: the first code is in index.html, but apparently it’s all good…

In the prototype.finish function:

if (this.name == "choicescript_stats" && this.originalScene) || "choicescript_stats King Relations" && this.originalScene) {

^There’s a closing parenthesis (bracket) before the first OR (||) - Remove that.

@CJW Still a no. Any other problems you’re seeing (and would this accursed Windows 8 count as a problem)?

From looking at the code I can’t see anything else wrong, but since there’s no error message - I don’t have a lot to go on.
It may not even be a problem with this, you may have mistyped a variable in mygame.js or something.

Is the game online? If it is PM me a link and I can take a closer look.

@CJW I don’t use mygame.js. And no, it’s still in my folder. Could it be because I don’t use mygame.js?

No, it won’t be because you don’t use mygame.js - Do you know how to use javascript debugging consoles on any of the browsers?

@CJW Alas, I’m not the tech-know type. I know how to write. I have half the game down. (In short, no)

I’m using the demo/template and I’m getting an error message telling me that “title” is non-existant command. That makes sense, but I’m not sure how to fix it.

@initdoby5 @adjppm1227
There’s only so much I can guess at when provided with limited information, unless you can get me an actual error message or (better) give me a copy of your game, I can only guess at what’s wrong - which would leave us here for days.

As for your “title” thing, that’s not an error with this mod, that’s something to do with raw choicescript - *title is a new command, maybe you have an old version of CS?

There’s an article on IE’s script debugger here: http://msdn.microsoft.com/en-us/library/dd565625(v=vs.85).aspx

If you use the debugger it *should* tell you what the problem is, once it does that, if you come back and tell me, I’ll be able to help you.

@CJW I used the debugger and two errors came up.

One: HTML1412: Malformed comment. Comments should start with "<!-- ".
dd565625, line 742 character 3

Two: SEC7115: :visited and :link styles can only differ by color. Some styles were not applied to :visited.
dd565625

Also, these came up.

013-05-01 17:41:0:997 : Loading comments…
2013-05-01 17:41:01:138 : Comment web service returned 10 comment(s)…

@adjppm1227 Check your index.html file, look for that malformed comment - and any other possible mistakes.

@CJW Alright, I’ll try that…

…and it doesn’t make sense. It says that the mistake is one line 742, but my index only goes to 105.

So I tried playing my game again, and, for some reason, it says, “This is an example game. This game requires JavaScript; please enable JavaScript and refresh the page.”

So thus, I have a question. How do you enable JavaScript?

That would depend on the browser, but it should be enabled by default? http://www.activatejavascript.org/en/instructions/ie