diff --git a/README.md b/README.md index 728c9c0..e9ec4a9 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,9 @@ If you need a lighter template without any console commands: [inkjs-boilerplate. * Keyboard support (press 1-9 to select 1th-9th choices, 0 to choose 10th) * Great game performance (all JS is ~200Kb in size with Inkjs runtime) * For authors: `npm watch` will auto-recompile the game on changes to JS or JSON + * Auto-recompiling from ink to JSON is not included, though +* Mobile-ready layout +* Editable color scheme ### Compatibility Compatible browsers: Chrome >= 60, Firefox >= 60, iOS >= 12, Safari >= 12. - -If you want to support older browsers (released before 2018), -you'll have to rewrite the CSS. -I use Bootstrap 5 because it's a good framework but it's also very modern. -Other than that, the code depends only on inkJS and jQuery so it should comfortably support IE9+ diff --git a/js/script.js b/js/script.js index 5197efc..bdb4df7 100644 --- a/js/script.js +++ b/js/script.js @@ -1,9 +1,26 @@ import jQuery from 'jquery' const inkjs = require('inkjs').Story; +/** + * Path to your game's compiled JSON. + * It is relative to index.html file. + */ const entryPoint = 'game/fogg.ink.json'; let continueToNextChoice, displayText, loadGame, saveChoice, s; +/** + * You can change this function. + * It's an easy way to define your own tags and text transformations. + */ +transform = function(text) { + text = text.replace('', ''); + text = text.replace('', ''); + return text; +} + +/** + * You don't need to change anything past this point. + */ saveChoice = function(index) { window.progress.push(index); return localStorage.setItem("progress", JSON.stringify(window.progress)); @@ -23,8 +40,7 @@ displayText = function(s, interactive = true) { for (j = 0, len = paragraphs.length; j < len; j++) { i = paragraphs[j]; if (i !== "") { - i = i.replace('', ''); - i = i.replace('', ''); + i = transform(i); html = jQuery.parseHTML(i); block = jQuery('

').html(html); if (interactive) { @@ -56,8 +72,7 @@ continueToNextChoice = function(s) { ref = s.currentChoices; for (j = 0, len = ref.length; j < len; j++) { choice = ref[j]; - let text = choice.text.replace('', ''); - text = text.replace('', '') + let text = transform(choice.text) jQuery("#options").append(`

  • ${text}
  • `); } jQuery("#options").fadeIn(500);