ID:2251859
 
Code:


Problem description:
I set up icons so they have lots of different states. In the reference manual it says you can set the icon_state of the pointer. For me it only works when I set the icon as an icon that has a state with no name, and that is always the state the pointer uses. How can you set it so it would use the icon, and icon state of an actual object being dragged?
You would have to generate an icon for it when you start to drag it. When you are dragging, your mouse pointer icon_state gets set to "drag". You don't really have control over this, all you can do is change the icon. When you have an icon file with no icon_states, it defaults to the blank one, which is why it occasionally was working for you.
var/icon/NewPointer=new()   //make a new blank icon
var/icon/I=new(Item.icon,Item.icon_state) //Create a new icon containing only the item
NewPointer.Insert(I,"") //Add the item to our blank icon, under a "" (blank) icon state
client.mouse_pointer_icon=NewPointer //Set the new icon

This is the easiest way I can think of to accomplish what you're looking for. I had this same problem years ago when I first messed with mouse icons and it drove me crazy trying to figure out the same issue you are having :)
client
New()
..()
mouse_pointer_icon = icon('icons.dmi',"pointer")


Compile-time setting requires a straight icon file, but at runtime you can set it to any valid icon object.