Lost in coding again


#1

Ok I have made a mess of this. I have several buttons but only want to make the blue print button disappear. Started to change the code but now the buttons are not working correctly, as in when I go to the stat screen I can click on the other buttons and nothing happens now. Or They just do not function at all after the first page. If someone could point out where I am making my error it would be greatly welcome. Thanks you all, with out you this project would have died long ago.
index file
`

Group info   Weapons   BlueprintsShow Blue Prints

`

ui file

`
function showStats1() {
if (window.showingStatsAlready) return;
window.showingStatsAlready = true;
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?")) {
          window.showingStatsAlready = false;
		  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 || "Fat", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton1").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}

function showStats2() {
if (window.showingStatsAlready) return;
window.showingStatsAlready = true;
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?")) {
          window.showingStatsAlready = false;
		  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 || "Fat", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton1").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}

function showStats3() {
if (window.showingStatsAlready) return;
window.showingStatsAlready = true;
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?")) {
          window.showingStatsAlready = false;
		  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 || "Fat", main, false, function() {
      window.stats.scene = currentScene;
      document.getElementById("statsButton1").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}
`


#2

The only thing I noticed wrong was that on both showStats2( ) and showStats3( ) you don’t reshow the correct buttons, you hide them correctly but don’t reshow them, see the the 2nd line from the end:
document.getElementById("statsButton1").style.display = "inline";
clearScreen(loadAndRestoreGame);

});

}

scene.execute();

}

Needs to be changed to statsButton2 and 3 for each respective function.

EDIT: You also have two closing button tags at the end of the index file:</button></button>

It might help if you change the names, I know the guide is statsbutton3, 2, 1 etc, but any name will work in practice and it’ll help vastly when trying to identify things.

Imagine you have five buttons that do five different things and the only difference is their trailing integer?

Just a random 2cents


#3

Thank you again @CJW


#4

Still having problems even after the changes, going to give it a break for now and start working on chapter two. Maybe come back to it tomorrow. Proably over looking something simple.


#5

What’s happening? Have you remembered to make a corresponding .txt scene for every function/button/page? Clicking them won’t do anything if there’s no page to load.

stats_scene_3.txt
stats_scene_2.txt
stats_scene_1.txt etc?


#6

The buttons do not function after the first page. And yes I have all three stat_scene.txt.
They all function until I started adding in the hide feature. It’s most likely some thing I have done wrong. What I may try is just a single button, make sure it works then hide it. Then add the code for the other two buttons. Hopefully I can track the problem down.


#7

Post your hide button function(s) when you get a chance?


#8

Sorry I got busy writing second chapter, will post tomorrow if I get a chance thanks.


#9

Ok I started a fresh copy and only worked on the the hide button only. Followed your direction from the other posts. I added the button and it is hiden, but when I add

`
function checkblueprints() {

if (stats.blueprints_found == true)

{

document.getElementById(“blueprintsButton”).style.display = “inline”;

}

else

{

document.getElementById(“blueprintsButton”).style.display = “none”;

}

}
`

I get the following error when opening the index
Expected “)”
So where did I screw up this time :stuck_out_tongue:
Thanks all


#10

Sorry there is more to the error
‘setStartingStatsClone’;object is null


#11

Good question, you’ve got a variable called “blueprints_found” under stats, right?


#12

Sorry sick as a dog will be back in day or to