ID:150239
 
Hello. I am making my first game where you can turn in to stuff, could somebody show me a code of like where if you touch something (not a touch verb) then it changes your icon the when you back away it changes back? It would be very helpful if somebody could show me this.


~PyRoMaNiAc~
mob
Bump(mob/M)
M.icon = 'something.dmi'
M.icon_state = "something"
verb
GoBack()
src.icon = initial(src.icon)
src.icon_state = initial(src.icon_state)
You could make a tile that is near what you want to change your icon, and use the Entered() Exited() procs to do it example:
turf/icon_changer
icon='Blah.dmi'
var/mob/M
var/last_icon=M.icon
Entered(M)
M.icon='Bleh.dmi'
Exited(M)
M.icon=last_icon


This code is not tested but it should work.
In response to Nadrew
turf/floor
icon='floor2.dmi'
var/mob/M
var/last_icon = 'pizza.dmi'
Entered(M)
M.icon = 'pizza.dmi'
Exited(M)
M.icon = 'pizzacrushed.dmi'

Thats what my code for the crush is. This is what happens when I try to compile it.

Funny game.dm:13:error:M.icon:bad var
Funny game.dm:15:error:M.icon:bad var


If anyone can help with this tell me.
In response to PyRoMaNiAc
duh, that means that M doesnt have any variables, because you havent told DM that it belongs to anything

Entered(mob/M) will do the trick.

FIREking