Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

How do I link variable images with

$
0
0
<<set $pies = [ "Blueberry", "Cherry", "Cream", "Pecan", "Pumpkin" ]>>

  <<set _x = $pies.pluck()>>


<<set $x = $pies.pluck()>>

 
I'll choose the <span id="pie"></span>, please.\
<<timed 3s>><<replace "#pie">><<link "OPTION 1" >><<print '<img src="' + $x + '.jpg" height="100" width="100">'  >> <<goto _x>> <</link>><</replace>>\
<<next>><<replace "#pie">><<link "OPTION 2" >><<goto $x>><<print '<img src="' + $x + '.jpg" height="100" width="100">'  >> <</link>><</replace>>\
<</timed>>
This doesn't work.
<<link [img[$x][$x]]>> <</link>> 
This ,while not what I want to set out to do, also doesn't work for various reasons which I dont understand. First <<link>> only reads $x as $x and not as a value from an array..

Okay, I got the image to work by putting the <<print ...>> code before the <<link>>.

That made me realize that the image will be the same one each time unless I can print $pies.pluck() instead of $x for the <<print>> image variable.

Perhaps a loop..



Edit 3:
IT works
<<timed 3s>><<replace "#pie">><<link "OPTION 1" >><<print '<img src="' + $pies.pluck() + '.jpg" height="100" width="100">'  >> <<goto _x>> <</link>><</replace>>\
<<next>><<replace "#pie">><<link "OPTION 2" >><<goto $x>><<print '<img src="' + $pies.pluck() + '.jpg" height="100" width="100">'  >> <</link>><</replace>>\
<</timed>>
Suddenly $pies.pluck() works for me and now my code goes through different random images.

I was used to $pies.pluck() not working
because of stuff like this
<<link [[$pies.pluck()|$t]] "$t">><</link>>

Viewing all articles
Browse latest Browse all 1844

Trending Articles