Note: This is a ‘hack’ and shouldn’t be used if you wish to publish your game through CoG - Instead you should use the supported method of a *choice command inside a stats screen to emulate multiple stats pages. The documentation for this method remains, but the demo download has since been removed. Use is discouraged.
@Marius recently drew my attention to a recent update to the choicescript interpreter which changes how the StatScene is handled. Due to this change the old method we used to add additional stat screens will no longer function as intended (if at all).
Now before I continue let me say: Choicescript’s update did not break your game.
Multiple stat screens are a concept the community came up with and are not (and never have been) supported or endorsed by CoG. When we ‘hack’ things like that, we don’t really have a right to complain about it, or expect them to fix it.
However, since many people have found this useful in the past and will probably continue to desire multiple stat screens in the future, I have come up with two (well one) solution(s):
- Just don’t upgrade
- If you really must (new author) or have already upgraded, I’ve devised something of a way to use multiple stat pages with the new code updates, and while it seems to work, it is not a perfect,clean and guaranteed to solve all your problems etc etc etc
The How
You’ll need to edit three javascript functions, in two of our favourite files, and of course add your buttons inside index.html and create your stat scene text files.
stat scene text files
index.html (add your buttons)
ui.js (edit two functions)
scene.js (edit one function)
Create Your Text Files
It does not matter what you call them, but try and keep it logical.
They go in the scenes folder like any other stat file:
Adding Buttons (Index.html)
Add a button for each of your stat pages here, note that unlike the old method the element’s ID does not matter, so you can leave them all as statsButton.
The important bit that you need to change is the text inside the showStats()'s brackets.
Here you need to put the name of the scene text file that particular button is supposed to open, without the file extension .txt and enclosed in SINGLE quotations ‘like so’.
function showStats() UI.JS
Things might start to get a little tricky here, so feel free to download the ‘demo’ pack from below and just copy and paste the ui.js from there, you’ll still need to make a few edits, but the bits that need changing are obvious enough.
I’ll try to keep it simple though:
- Add the word scene inside the brackets of 'showStats()', like this: showStats(scene).
- On the line beginning with var scene = new Scene("choicescript_stats"... Etc - Replace "choicescript_stats" with the word scene, without quotation marks.
- Add an additional IF after the first one's FIRST curly brace: `if (window.stats.sceneName == scene) { `
- Move the next three lines of code (clearScreen, return etc..) to be after your NEW (second) if and then add an additional curly brace after return; to close the new if.
- Lastly, return to the first if - the one with "choicescript_stats" in it. You need to use javascript's or operator which is || to add all your stat screens to this if (see the picture below).
function printFooter() UI.JS
Much easier, in this function we’re merely commenting out (or deleting, but I recommend commenting) out code using two forward slashes before a line //This is a comment.
Or using opening and closing comment tags: /* This is a comment */
See the picture below for exactly what needs commenting out.
*finish command - Scene.js
Now inside the scene.js file find the *finish command function and repeat a step similar to the last one on the showStats() function. We just need to edit the condition to include all our new scenes with || operator.
Take care however to re-include the “&& this.originalScene” for every single or (see picture).
If all else fails, check the pictures and/or download the template and trial and error edit:
Demo/Template
Removed by AuthorI hope this helps people, I tried to keep both the method and implementation/tutorial as simple as possible and the lack of any real explanation is part of that. Please let me know if you encounter any problems.
Things to Note
- The stats screen buttons will not change or hide/appear - they’re always there.
- Clicking a second stats button while in another stats screen will take you to the new stats screen.
- Clicking the stats button belonging to the stats screen you’re currently on will return you to the game.
- Clicking next at the bottom of any stats pages will return you to the game.