+1 vote
by (2.2k points)

I have a small character customization screen that I would like to have a picture to display the outcome (you can only choose hair and eye color so it's not that cool), I've got the right side bar that greyelf commented on the old forum a while ago, and the impending doom of writing a mountain of code for this side bar so it knows what picture to display.

I'm thinking it'd look something like this

<<if $var1 is "color" and $var2 is "another color">> (however you link to pictures, I'm in the process of learning that, several tabs open and plenty of tears open, the whole package, lol)

But that times 25, which seems like a hella lot of stuff for one passage that will, on top of that, show at least 6 other variables. 

I imagine it'd be hard to format as well. I'm getting exhausting just thinking about it.

So basically, my question is "is there a simpler code that what I'm anticipating?"

1 Answer

+1 vote
by (159k points)
selected by
Best answer

You can use variables to story the components of the image name, then assemble the variables to determine the full image name, and final use Image Markup to display the correct image.

/% the current colour names are assigned somewhere in your story. %/
<<set $varA to "red">>
<<set $varB to "blue">>

/% Determine which image to show and then display it.
   the following equals "portrait-red-blue.jpg"
<<set $image to "portrait-" + $varA + "-" + $varB + ".jpg">>

... obviously name the variables whatever makes sense in  your story, and the same goes for the composite images names. Just be consistent in the image naming scheme.

by (2.2k points)
edited by

how do I set an image to a variable? in my sleep deprived state, I thought I was asking what I needed to know, but I did not, since you clearly spelled it out for me. Forgive me.

Thanks for your help, that is much simpler.