From c8a80ad17b2cae5c2158d1687ff7777f02148cd6 Mon Sep 17 00:00:00 2001 From: kopareigns <kopareigns@gmail.com> Date: Sun, 13 Jan 2019 20:12:22 -0500 Subject: [PATCH] Fix and jsInclude function --- devNotes/twine JS.txt | 8 ++++++++ src/art/artJS.tw | 29 +++++++++++++---------------- src/js/utilJS.tw | 8 ++++++++ 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index cfe7e68e942..3d6a4642c45 100644 --- a/devNotes/twine JS.txt +++ b/devNotes/twine JS.txt @@ -4085,6 +4085,14 @@ window.html5passage = function html5passage(passage_function) { }); }; +//If you want to include a SugarCube passage in a JS function use this. The result must be printed using the <<print>> macro. +window.jsInclude = function(passage) { + if (Story.has(passage)) + return Story.get(passage).processText(); + else + return `<span class="red">Error: Passage ${passage} does not exist.</span>` +}; + window.capFirstChar = function capFirstChar(string) { return string.charAt(0).toUpperCase() + string.substr(1); }; diff --git a/src/art/artJS.tw b/src/art/artJS.tw index 6b0aaae4a69..108e4e40f8f 100644 --- a/src/art/artJS.tw +++ b/src/art/artJS.tw @@ -1735,20 +1735,20 @@ window.skinColorCatcher = function (artSlave) { window.ArtVectorAnalAccessories = function(slave) { let r = ""; - if (slave.buttplug == "long plug") + if (slave.buttplug === "long plug") r += Story.get("Art_Vector_Plug_Long").processText(); - else if (slave.buttplug == "large plug") + else if (slave.buttplug === "large plug") r += Story.get("Art_Vector_Plug_Large").processText(); - else if (slave.buttplug == "long, large plug") + else if (slave.buttplug === "long, large plug") r += Story.get("Art_Vector_Plug_Large_Long").processText(); - else if (slave.buttplug == "huge plug") + else if (slave.buttplug === "huge plug") r += Story.get("Art_Vector_Plug_Huge").processText(); - else if (slave.buttplug == "long, huge plug") + else if (slave.buttplug === "long, huge plug") r += Story.get("Art_Vector_Plug_Huge_Long").processText(); - if (slave.buttplugAttachment == "tail") + if (slave.buttplugAttachment === "tail") r += Story.get("Art_Vector_Plug_Tail").processText(); - else if (slave.buttplugAttachment == "cat tail") + else if (slave.buttplugAttachment === "cat tail") r += Story.get("Art_Vector_Cat_Tail").processText(); return r; @@ -1844,7 +1844,6 @@ window.ArtVectorBoobAddons = function(slave) { window.ArtVectorButt = function(slave) { const T = State.temporary; - let r; /* TODO: turn _buttSize into a scoped JS variable */ /* BEWARE: _buttSize is also used in Art_Vector_Leg_ */ @@ -1868,17 +1867,15 @@ window.ArtVectorButt = function(slave) { T.buttSize = 0; if (slave.amp == 0) - r = `Art_Vector_Butt_${T.buttSize}`; + return Story.get(`Art_Vector_Butt_${T.buttSize}`).processText(); else if (slave.amp == -1) - r = `Art_Vector_Butt_ProstheticBasic_${T.buttSize}`; + return Story.get(`Art_Vector_Butt_ProstheticBasic_${T.buttSize}`).processText(); else if (slave.amp == -2) - r = `Art_Vector_Butt_ProstheticSexy_${T.buttSize}`; + return Story.get(`Art_Vector_Butt_ProstheticSexy_${T.buttSize}`).processText(); else if (slave.amp == -3) /* reverted to regular SVG to match description */ - r = `Art_Vector_Butt_ProstheticBeauty_${T.buttSize}`; + return Story.get(`Art_Vector_Butt_ProstheticBeauty_${T.buttSize}`).processText(); else if (slave.amp == -4) - r = `Art_Vector_Butt_ProstheticCombat_${T.buttSize}`; + return Story.get(`Art_Vector_Butt_ProstheticCombat_${T.buttSize}`).processText(); else if (slave.amp == -5) - r = `Art_Vector_Butt_ProstheticSwiss_${T.buttSize}`; - - return Story.get(r).processText(); + return Story.get(`Art_Vector_Butt_ProstheticSwiss_${T.buttSize}`).processText(); }; diff --git a/src/js/utilJS.tw b/src/js/utilJS.tw index 290ef982bb6..c65c2f4512f 100644 --- a/src/js/utilJS.tw +++ b/src/js/utilJS.tw @@ -700,6 +700,14 @@ window.html5passage = function html5passage(passage_function) { }); }; +//If you want to include a SugarCube passage in a JS function use this. The result must be printed using the <<print>> macro. +window.jsInclude = function(passage) { + if (Story.has(passage)) + return Story.get(passage).processText(); + else + return `<span class="red">Error: Passage ${passage} does not exist.</span>` +}; + window.capFirstChar = function capFirstChar(string) { return string.charAt(0).toUpperCase() + string.substr(1); }; -- GitLab