ID:143287
 
Code:
mob/verb/shrink_me()
usr.icon = initial(icon)
usr.overlays.len = 0
var/icon/I = new(icon)
I.Scale(16,16)
usr.icon = I
mob/verb/enlarge_me()
usr.icon = initial(icon)
var/icon/I = new(icon)
I.Scale(64,64)
for(var/i = 2 to 4)
var/obj/O = new
O.icon = I
var/a = i>2
var/b = (i-1)%2
O.icon_state = "[a],[b]"
O.pixel_x = a*32
O.pixel_y = b*32
usr.overlays += O
mob/verb/normal()
icon = initial(icon)


Problem description: When you click on enlarge me, it makes the icon disappear.
Also, when you remove the icon = inital(icon)line, it works, but not fully. The bottom left is normal, the rest is big.

Strong123488 wrote:
Code:
mob/verb/shrink_me()
> usr.icon = initial(icon)
> usr.overlays.len = 0
> var/icon/I = new(icon)
> I.Scale(16,16)
> usr.icon = I
> mob/verb/enlarge_me()
> usr.icon = initial(icon)
> var/icon/I = new(icon)
> I.Scale(64,64)
> for(var/i = 2 to 4)
> var/obj/O = new
> O.icon = I
> var/a = i>2
> var/b = (i-1)%2
> O.icon_state = "[a],[b]"
> O.pixel_x = a*32
> O.pixel_y = b*32
> usr.overlays += O
> mob/verb/normal()
> icon = initial(icon)
>

Problem description: When you click on enlarge me, it makes the icon disappear.

   usr.icon = initial(icon)

Loads the compile time value. What is the value of mob/icon at compile time? If you didn't set it then it is null. Thus, not only the icon but also all the objects added to your overlays list are null as well.

Also, when you remove the icon = inital(icon)line, it works, but not fully. The bottom left is normal, the rest is big.


This is because you never change the mob's icon_state to "0,0". After scaling the icon, your icon object now contains five different icon_states. One is the blank icon state, which is a thumbnail of the bigger icon. Then you have the four coordinate icon states. Thus not changing the icon_state to "0,0" keeps your user's icon at the thumbnail state.