ID:679404
 
Code:
mob
proc
Dash_Effect(location)
var/obj/d1 = new()
d1.name = "[src] Dash Mode"
d1.icon = src.icon
d1.overlays = src.overlays
d1.dir = src.dir
d1.loc = location
d1.icon -= rgb(120,120,120,160)
spawn(5) del(d1)
mob
verb
Dash()
set hidden = 1
usr.dashing = 1
step(usr,usr.dir)
usr.Dash_Effect(usr.loc)


Problem description:
Well since im not good at iconing can someone help me with creating a code that save the modified state into my icon with a different state name.

Because if i use d1.icon -= rpg(120,120,120,160) it makes lag when someone uses dash


If this is going to be a state which any player can use, I suggest doing the following:
var/list/states = list() // a list of states created
mob/proc
Dash_Effect(location)

// if the dash icon_state does not exist
if(!("dash_icon_state_name" in states))

// create one and store it in the states list
var/icon/i = new
i = icon
i -= rgb(120, 120, 120, 160)

states += "dash_icon_state_name"
states["dash_icon_state_name"] = i

var/prev_icon = icon // this stores your previous icon

// grab the dash icon from the states list
icon = icon(states["dash_icon_state_name"])
spawn(10) icon = prev_icon // return to the previous state 1 second later