ID:159462
 
I'm trying to change the image parameter of a button control at runtime. The method detailed in [link] works for images stored on the hard drive (and loaded into the catche), but I can't get it to work for images generated dynamically.

Here's an example of how I generate the icon, and all the ways that this doesn't work:
var /icon/dynamic_icon = icon('some_file.dmi', "icon_state", NORTH)

winset(src, "control_id", "image=[dynamic_icon]")
winset(src, "control_id", "image='[dynamic_icon]'")
winset(src, "control_id", "image=\ref[dynamic_icon]")
winset(src, "control_id", "image='\ref[dynamic_icon]'")
src << browse_rsc(dynamic_icon, "test.png")
winset(src, "control_id", "image='test.png'")


None of those file attempts cause errors or any other odd behavior, except that they simply don't work. As it stands, I don't see any way to set a button's image parameter to a dynamically generated image.

Anyone else have any ideas?
You could try this, which is what I had to do when I was changing images at runtime.
[link]
In response to AJX
Thanks for the info.

Zaltron has informed me that fcopy_rsc() can be used to make this work.

var/whatever = fcopy_rsc(icon)
winset(client, control_id, "image=\ref[whatever]")
In response to IainPeregrine
Also, if you set any atom's icon to a dynamically generated image, it's the equivalent to fcopy_rsc(); if you're using the image in both an interface control and on the map, fcopy_rsc() is unnecessary.