diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index cfe7e68e942ec925f5c75c4d85b96a371dd3a602..30ff7a15b71ce408587e441fefb449b46e25a5e5 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. passageTitle must be a string. +window.jsInclude = function(passageTitle) { + if (Story.has(passageTitle)) + return Story.get(passageTitle).processText(); + else + return `<span class="red">Error: Passage ${passageTitle} 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 6b0aaae4a696dcfb7f2becf056072bccec9c8a53..108e4e40f8f5966cd108c4e3d92b4d24b77040af 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 290ef982bb62cfcef647c6d1578c6d2d867881f4..346883935e365e7ee264878e96f464581f9c725d 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. passageTitle must be a string. +window.jsInclude = function(passageTitle) { + if (Story.has(passageTitle)) + return Story.get(passageTitle).processText(); + else + return `<span class="red">Error: Passage ${passageTitle} does not exist.</span>`; +}; + window.capFirstChar = function capFirstChar(string) { return string.charAt(0).toUpperCase() + string.substr(1); };