obj
Medals
icon = 'Medals.dmi'
icon_state = ""
mob
player
icon = 'player.dmi'
verb
Add_Medal()
var/obj/Medals/T
var/IS
var/MN
if(!T in src.overlays)
src.overlays += T
return
if(T in src.overlays)
IS = T.icon_state
del T
MN = text2num(IS)
MN += 1
src.overlays += T
T.icon_state = "gold[MN]"
return
ID:147850
Oct 30 2003, 11:35 pm
|
|
I'm attempting to make a medal system, and of course, I'm already stumped. I'm trying to make the medal appear as an overlay, and if the medal exists, I want it to delete the overlay, add one to the icon state and add the overlay again.
|
In response to Spuzzum
|
|
Well, I tried what you gave me Spuzzum, and most likely I messed up somewhere.... it adds the medal the first time I click the verb, but doesn't seem to do anything else...
obj |
In response to Enigmaster2002
|
|
Bump.
|
The problem here is that an object isn't stored in overlays -- rather, a "snapshot" image is generated of a particular object, and that image is added or removed from the overlays list when the code specifies to add/remove the object.
Here's how I would do it:
mob
player
icon = 'player.dmi'
var/obj/Medals/medal
proc/IncreaseMedal()
if(!medal) //if we don't have a medal...
medal = new /obj/Medals
overlays += medal
return
//otherwise...
overlays -= medal
var/IS = medal.icon_state
var/MN = text2num(IS) + 1
medal.icon_state = "gold[MN]"
overlays += medal
(Might also be a good idea to have the following code:
Write()
//remove overlay before saving
overlays -= medal
..()
Read()
..()
//add overlay upon loading
if(medal) overlays += medal
...just so your overlay doesn't get "stuck" on a character on save/load.)