ID:273137
 
I'm making a RTS, and I want it so that when you click the unit in the "Buy" tab, your mouse pointer turns into the same icon that the thing is.

    Recruit
icon_state ="recruit"
Click()
if(usr.purchasing ==1) return
if(usr.points >=100)
usr.points -=100
usr<<"Recruit unit has been purchased. Click anywhere on the screen to create the unit."
usr.purchasing =1
usr.client.mouse_pointer_icon =//???


It works if I just use something like 'Recruit.dmi', but I don't want to have to make a seperate DMI file for every single unit in the game. Any ideas?
You'll have to have a unique icon for each, as the icon_state is specified by the condition of the pointer (ie: dragging vs. hovering). You can, however, dynamically generate an icon as needed:

usr.client.mouse_pointer_icon = icon(src.icon, src.icon_state)


Ideally you could also cache these so that you don't have to generate a new icon file every time, but the effort required to do that outweighs the minor (and almost certainly unnoticeable) benefit.
In response to Garthor
Yes! It works! Thanks!