+1 vote
by (250 points)

Bottom Line:  How do I set a variable in StoryInit to point to a base64-encoded image from a Twine.image passage?

I currently have widgets defined (see below) which display an image using specific css classes.

<<widget "antagonist">><img src="images/antagonist_small.jpg" alt="No-Way Jay" class="w3-animate-zoom w3-padding-small"><</widget>>

Additionally, I have variables defined in my StoryInit passage (see below) which allow me to reference character names and images.

<<set $antagonist = { name:"\"No Way Jay\"", image:"images/antagonist_small.jpg"}>>

I've recently created Twine.image-tagged passages (e.g., antagonistImage) so that I can embed all images in my story rather than accessing local file storage.

My problem is that I do not know how to use <<set>> in my StoryInit passage to point to images stored in Twine.image passages.  I've tried the following and it does not work:

<<set $antagonist = { name:"\"No Way Jay\"", image:"data-passage=\"antagonistImage\""}>>

Any help someone can give me would be greatly appreciated!

1 Answer

0 votes
by (159k points)
selected by
Best answer

Why not assign the embedded image's Passage Name to the object's image property instead.

eg. Assuming that the antagonist_small.jpg image file was embedded into a passage named "antagonist".

<<set $antagonist = { name: "\"No Way Jay\"", image: "antagoniste" }>>

You could then use that Passage Name later when you are generating the code required to display that image.

by (250 points)

Thank you, greyelf, that worked perfectly!