Layering Pictures

I found some good information here:
https://textadventures.co.uk/forum/quest/topic/4978/hmm-image-layering
I was able to get the get the function that The Pixie had created working. Now how do I change out the pictures midgame? Can I use some variable and reassign pictures pictures with a script?

I don't know coding so i'm stumped.


I would suggest making a javascript function to let you substitute the images.

The javascript would look like:

function changeImageLayer (number, url) {
  $("#image" + number).attr("src", url);
}

which wrapped up in Quest code would look like:

JS.eval ("window.changeImageLayer=function(i,j){$('#image'+i).attr('src',j)}")

Then when you want to swap image2 from m_red_cape.png to m_blue_cape.png you can just do:

JS.changeImageLayer (2, GetFileURL ("m_blue_cape.png"))

Note that this method will revert to the default when a saved game is loaded; so you will need to display the right item in your UI Initialisation script.

If you want to make it a little easier to automate, you could create attributes for each item, and then use changescripts.
It's hard to come up with a generic version of this function, because there's so many details that could vary. But if you need help, I'd be happy to throw together some quick code off the top of my head.


Thank you so much!!! I'll give this a try.


Log in to post a reply.

Support

Forums