ID:261760
 
I'm having trouble assigning a layer here for the item that's being created.

obj/hair
icon = 'hairmale.dmi'
Click()
var/U = usr
var/haircolor = F_Color_Selector.Get_Color(U)
var/icon/I = new('hairmale.dmi')
I.Blend(haircolor)
usr.overlays += I


I realize that I'm only creating an icon and that by doing that I can't really assign a layer to it, Or can I? If yes then how? And if not, then how would I go about creating a type of obj that has the layer assigned to it. Note that I am using Flick's Color selector, though I'm sure you realized that. Help is greatly appreciated.

Thanks,
Resonating Light

Resonating_Light wrote:
I'm having trouble assigning a layer here for the item that's being created.
obj/hair
icon = 'hairmale.dmi'
Click()
var/U = usr
var/haircolor = F_Color_Selector.Get_Color(U)
var/icon/I = new('hairmale.dmi')
I.Blend(haircolor)
usr.overlays += I

You'll have to use I.Blend(haircolor,ICON_MULTIPLY) here to get this to work well.

I realize that I'm only creating an icon and that by doing that I can't really assign a layer to it, Or can I? If yes then how? And if not, then how would I go about creating a type of obj that has the layer assigned to it. Note that I am using Flick's Color selector, though I'm sure you realized that. Help is greatly appreciated.

Don't add an icon as the overlay; create an obj, set the icon to that, and then add it. (I don't think an /icon can be added directly as an overlay anyway, as far as I know, because it's not the same as a regular icon.)
var/obj/O = new
O.layer = ...
usr.overlays += O
del(O) // it's safe to delete it; the overlay will stay

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Don't add an icon as the overlay; create an obj, set the icon to that, and then add it. (I don't think an /icon can be added directly as an overlay anyway, as far as I know, because it's not the same as a regular icon.)
var/obj/O = new
> O.layer = ...
> usr.overlays += O
> del(O) // it's safe to delete it; the overlay will stay

Lummox JR

Well, first of all, my original coding did work so you could put /icon as an overlay. And second of all, I got a new error.

obj/hair
icon = 'hairmale.dmi'
layer = HAIR
Click()
var/U = usr
var/haircolor = F_Color_Selector.Get_Color(U)
var/obj/O = new(src) //creat a new src instead of a new icon
O.Blend(haircolor) //had to switch this to O
usr.overlays += O
del(O)

I altered itlike you said and now I get
O.Blend:undefined proc

I've actually tried something similar to this before and recieved the same error. I imagine it is because Blend only works for an actual icon and not a obj or turf alike.

Resonating Light
In response to Resonating_Light
maybe it should be O.icon.Blend()
In response to Jp
Jp wrote:
maybe it should be O.icon.Blend()

Tried that, didn't work.

Resonating Light
In response to Resonating_Light
Resonating_Light wrote:
Well, first of all, my original coding did work so you could put /icon as an overlay. And second of all, I got a new error.

obj/hair
> icon = 'hairmale.dmi'
> layer = HAIR
> Click()
> var/U = usr
> var/haircolor = F_Color_Selector.Get_Color(U)
> var/obj/O = new(src) //creat a new src instead of a new icon
> O.Blend(haircolor) //had to switch this to O
> usr.overlays += O
> del(O)

I altered itlike you said and now I get
O.Blend:undefined proc

You "had to switch" that to O?
No you didn't. You left out part of your original code--and didn't fix the one part I did tell you to fix, the Blend() proc.
var/icon/I = new('hairmale.dmi')
I.Blend(haircolor)
Look familiar? That should still be in there. Except you have to use ICON_MULTIPLY as the second argument to Blend(), like I said.

One thing I did forget, though, was to actually assign the icon to O.
O.icon = I
You've also got an indentation problem with the del(O) line that you need to clear up; it's indented with spaces, not tabs.

I've actually tried something similar to this before and recieved the same error. I imagine it is because Blend only works for an actual icon and not a obj or turf alike.

Correctamundo. Which is why you should have left those two lines with I intact, except for changing the Blend() proc to use ICON_MULTIPLY.

Lummox JR
In response to Lummox JR
I got it finally! I was reading your messages wrong. Which is why I left out that one stuff, the way I interpreted it made me think I really didn't have to do some of that stuff. And the del(O) problem was because I didn't catch it when I copyied from my game and pasted it so I just typed out the del(O) thing.... Sooooo I think I got it now. Let me go over it though to make sure.

So what i'm doing is first creating an obj and coloring it with Flick_Color() and Blend, then I create an obj and give it a layer and an icon then add it as an overlay. Was that right?

Resonating Light
In response to Resonating_Light
Resonating_Light wrote:
I got it finally! I was reading your messages wrong. Which is why I left out that one stuff, the way I interpreted it made me think I really didn't have to do some of that stuff. And the del(O) problem was because I didn't catch it when I copyied from my game and pasted it so I just typed out the del(O) thing.... Sooooo I think I got it now. Let me go over it though to make sure.

So what i'm doing is first creating an obj and coloring it with Flick_Color() and Blend, then I create an obj and give it a layer and an icon then add it as an overlay. Was that right?

That ought to do it.
Depending on what you need it might be easier to do it all with the custom icons without using overlays at all, but I doubt you need a more complex system right now. So if it ain't broke, don't fix it. ;)

Lummox JR
In response to Lummox JR
Lummox JR wrote:
That ought to do it.
Depending on what you need it might be easier to do it all with the custom icons without using overlays at all, but I doubt you need a more complex system right now. So if it ain't broke, don't fix it. ;)

Lummox JR

Hold on one sec! I'm always looking to improve things, so uhhh... tell me a little more about this more complex system. I just might take it into cosideration. Probably for a future project or something though since it may be a little too difficult for me right now. But tell me more, I'm intrigued. If you don't mind of course. It's no biggy if you don't.

Resonating Light