Twine Version: 2.35
Story Format: Sugarcube 2.33.2
Hi - I’m trying to get the output of various passages into an array, and then to iterate through the array displaying them with various effects and timings. Some passages if rendered on their own would be empty (due to conditional logic or randomisation). I need to be able to not add these to my array as they mess with formatting and timing. Passage.processText() gets me the semi-processed text but the logic contained in it will always be processed when text gets added to the DOM as best I can tell- ie even something which will generate no output won’t give me an empty string. jQuery.wiki() wants to add it straight to the DOM which I don’t want to do yet. Basically I want to get the equivalent of the output of the <> macro straight into a variable. Is there a way I can do this please?
My (not-working) code:
<<set $homeBits=[]>>
<<set $homeBits.push(Story.get("Home top description").processText())>>
<<set _fridge= Story.get("Home Fridge Magnet").processText()>>
<<if _fridge!="">><<set $homeBits.push(_fridge)>><</if>>
<<set _quiz= Story.get("Home Quiz Description").processText()>>
<<if _quiz!="">><<set $homeBits.push(_quiz)>><</if>>
<<set _pamphlet= Story.get("Home Pamphlet Description").processText()>>
<<if _pamphlet!="">><<set $homeBits.push(_pamphlet)>><</if>>
<<set _lamp= Story.get("Home Lamp Description").processText()>>
<<if _lamp!="">><<set $homeBits.push(_lamp)>><</if>>
<<set _vodka= Story.get("Home Vodka Description").processText()>>
<<if _vodka!="">><<set $homeBits.push(_vodka)>><</if>>
<<set _delay=3>>
<<for _i=0; _i<$homeBits.length; _i++>>
<<set _myDelay=(_delay*_i)+"s">>
<<capture _myDelay, $homeBits, _i>>
<<set _left=random(-200,200)>>
<<set _leftstyle="left:"+_left+"px">>
<div class="homebit" @style=_leftstyle><<timed _myDelay t8n>><<print $homeBits[_i]>><</timed>></div>
<</capture>>
<</for>>
Thanks!