ID:149998
 
The following is some code from a game I'm working on, I am using the rgb() proc to alter icons so that I don't have to have the players download 25 diffrent icons that are only difrrent colors. Hoping to make things quicker to download... Anyways, this code works fine, except when I hit the more_stuff_03() verb (all non-essential info has been changed to conceal the game's identity). It is supposed to cuase an obj to toggle on and off under the player.. but it only turns it on. Unless I comment out the New() lines where the rgb() is called. Why!?!?

obj
stuff
icon = 'stuff.dmi'

New() // if I comment out this part, it
// works fine, and the object
// appears and disapears, as it should...
.=..()
src.icon += rgb(0,10,0)
src.icon -= rgb(10,0,10)
// commented out to here, that is... eliminating this call to New()

more_stuff_01
m_s01
icon_state = "more_stuff11"
m_s02
icon_state = "more_stuff12"
m_s03
icon_state = "more_stuff13"
m_s04
icon_state = "more_stuff14"
m_s05
icon_state = "more_stuff15"
m_s06
icon_state = "more_stuff16"
m_s07
icon_state = "more_stuff17"
m_s08
icon_state = "more_stuff18"
m_s09
icon_state = "more_stuff19"

more_stuff_02
icon_state = "more_stuff_03"
layer = -20

more_stuff_03
icon_state = "more_stuff01"

mob
player
icon = 'player.dmi'
icon_state = "01"

var
more_stuff_02 = 0
more_stuff_03 = 0

verb

say(msg as text)
world << "[usr.key]: [msg]"

more_stuff_02()
if(more_stuff_02)
overlays -= /obj/stuff/more_stuff_02
src.more_stuff_02 = 0
else
overlays += /obj/stuff/more_stuff_02
src.more_stuff_02 = 1

more_stuff_03()
if(!more_stuff_03)
src.icon += rgb(31,31,0)
src.icon -= rgb(0,0,71)
underlays += new/obj/stuff/more_stuff_03()
src.icon_state = "03"
src.more_stuff_03 = 1
else
src.icon += rgb(0,0,71)
src.icon -= rgb(31,31,0)
underlays -= /obj/stuff/more_stuff_03
src.icon_state = "01"
src.more_stuff_03 = 0


Please, I would really like to know what's going on here...

~X
It looks to me like when you add more_stuff_03 to the underlays, you're creating a new object to do it; yet when you take it back out, you're not actually taking the object out of underlays but subtracting its type. My guess is that underlays -= /type only works when the underlay (or overlay) was added with underlays += /type, but since you created an object for it it uses the object instead. To get rid of it, I think you'd have to either reset underlays or keep track of which objects you added to the list and remove them specifically.

Lummox JR
In response to Lummox JR
Yes, in order for the rgb() modification to affect the underlay, I had to create an new object, not just reference the object type. I decided to use the Cut() proc to delete the list, as I don't plan on having any other underlays. Although, I might change my mind, who knows...

Thanx Lummox JR!

~X :-)