All was looking do something I have no clue on lol

Ok this is an area I have very little understanding. This is what I would like to do.
At a certain piont in the game the pc is handed blueprints, theses are important. Now can I make a new stat button showup at this time. From the stat they can flip through the blueprints. I figure I am reaching to far. The other thought is perhaps add a button that will open small new window that I have linked to my website that I can use simple html and javascript to allow the player to flip through the blueprints.

Yes, you can make a hidden button in the index.html file and unhide it with j/s when required.

At least thatā€™s the theory.
The difficult bit is defining an event for unhiding the button in javascript, since from personal experience ā€œonload=ā€ doesnā€™t work too well and choicescript never loads a new page, it just changes the content displayed on the same one.

You could have a ā€˜refreshā€™ button that will act as a trigger making a new button appear if a condition is true when pressed (which you can set in c/s), but thatā€™s probably not ideal. Iā€™ll let you know if I find a way of checking the variable more often.

So if I make ā€˜blueprintā€™ flase then they receive the blueprints turn it true I have it refresh to show the new button?

In index.html have your hidden button:
<button id="blue_prints" onclick="showBluePrintsPage()" style="display:none;"</button>

^See the multi stat page thread for how to make the page/Iā€™m assuming you already have one

Then in mygame.js
function showblueprintbutton() { if (stats.blueprints == true) { document.getElementById("blue_prints").style.display = "inline"; }

All you need on top of that is an EVENT that calls showblueprintbutton()

Thanks will try it out today.

@CJW and @Lordirish, to call the showblueprintbutton() function as in your example, I think you can call it from the CS code when it is most appropriate for the button to appear. I canā€™t verify the code right now (and Iā€™m leaving soon for a 4-day trip), but I believe the *script command is enabled by default, so you should be able to enter the following at the appropriate place in your CS file:


*script showblueprintbutton()

If that is the case, then my hat off to you sir, I canā€™t express how much of a pet hate that has become of mine. Iā€™ll check it out when I get home.

Just opened scene.js on my phone and damn, it is so!
Kudos my friendā€¦ Iā€™ll have to look into that some more, :smiley:

And if that works, you could also have a function and a corresponding *script command that hides the button when they lose the blueprints!

That helps a lot thank you and for giving me an evilā€¦ I mean good idea.

Ok I can follow some of what is going on but can anybody kinda walk me through where to put the code and what it should look like thanks. Lol not feeling so bright since I started this coding stuff.

Ok ^^ā€™

Index.html

  1. Find:

<p><button id="statsButton" onclick="showStats()">Show Stats</button></p>

  1. Replace with:
    <p><button id="statsButton" onclick="showStats()">Show Stats</button> <button style="display:none;" id="blueprintsButton" onclick="showBlueprints()">Show Blue Prints</button></p>

^The display:none; makes sure the button is hidden when the game is first loaded.

ui.js

  1. Find:

`function showStats() {
if (window.showingStatsAlready) return;
window.showingStatsAlready = true;
document.getElementById(ā€œstatsButtonā€).style.display = ā€œnoneā€;
main.innerHTML = ā€œ

ā€;
var currentScene = window.stats.scene;

var scene = new Scene("choicescript_stats", 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("statsButton").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;
      window.showingStatsAlready = false;
      document.getElementById("statsButton").style.display = "inline";
      clearScreen(loadAndRestoreGame);
  });
}
scene.execute();

}`

  1. Copy and paste the above below - so you have two copies of the same code in the same file.

  2. Change the following lines in ONE of the blocks of code, it doesnā€™t matter which one:

function showStats()
With
function showBlueprints()

document.getElementById("statsButton").style.display = "none";
With
document.getElementById("blueprintsButton").style.display = "none";

var scene = new Scene("choicescript_stats", window.stats, this.nav);
With
var scene = new Scene("blue_prints", window.stats, this.nav);

document.getElementById("statsButton").style.display = "inline";
With
document.getElementById("blueprintsButton").style.display = "none";

^The change to none is important, as you donā€™t want this particular button to appear if someone restarts their game/this is inside the function call for restart.

Same again with the final instance:
document.getElementById("statsButton").style.display = "inline";
With
document.getElementById("blueprintsButton").style.display = "none";

blue_prints.txt

Create a file with this name inside /scenes/

mygame.js

  1. Create a new stat variable:

,blueprints_found: false

  1. Create the hide/unhide function right at the bottom/below everything in the mygame.js file:

`
function checkblueprints() {

if (stats.blueprints_found == true)
{
document.getElementById(ā€œblueprintsButtonā€).style.display = ā€œinlineā€;
}
else
{
document.getElementById(ā€œblueprintsButtonā€).style.display = ā€œnoneā€;
}
}
`

^This function, when called, will show the button if our created variable has been set to true and hide it if it is false.


FINAL STEP

Use:
*set blueprints_found true *script checkblueprints()

To make the button appear

Or:
*set blueprints_found false *script checkblueprints()

To make the button disappear, anywhere in your choicescript scenes.

ā€¦I donā€™t think I missed anything, if you need more elaboration let me know ^^ā€™

@CJW
You my friend ROCK, I will try this out tonight. Thank you very much. :slight_smile:

Hey, no problem ^^
Let me know how it goes!

1 Like