Posts ID:145428 Favorites
ID:145428

Code:
 mob barber DblClick() if(!(src in oview(1))) return 0 switch(input("What hair style would you like me to do for you today?")in list("Bald", "Gaara - 10", "Chouji - 10", "Nothing")) if("Bald") usr.removehair() usr.removehair() if("Gaara - 10") if(usr.Yen >= 10) usr.Yen -= 10 usr.removehair() var/obj/hairs/GaaraHair/a=/obj/hairs/GaaraHair usr.crgb(a)mob/proc/crgb(obj/a) var/r=input(src,"How much red should the hair have? Between 0 and 255!") as num var/g=input(src,"How much green should the hair have? Between 0 and 255!") as num var/b=input(src,"How much blue should the hair have? Between 0 and 255!") as num if(r>255) r=255 if(r<0) r=0 if(g>255) g=255 if(g<0) g=0 if(b>255) b=255 if(b<0) b=0 a.icon+=rgb(r,g,b) src.Overlays+=a src.update()

Problem description: Runtime error that it can't read /obj/hairs/'whateverhairIpicked'.icon
This sounds quite obvious, but I have no clue how to fix it. As you can see, I'm using 'Overlays' instead of 'overlays', being it that it's handyer and doensn't mess up overlays.
Any thoughts?

You can use min() and max() for that.

 r = min(max(0,r),255)...etc
 #2 Mar 22 2006, 11:17 am In response to Papoose (#1) Euh, that's nice, but doesn't quite solve me problem :/
 mob barber DblClick() if(!(src in oview(1))) return 0 switch(input("What hair style would you like me to do for you today?")in list("Bald", "Gaara - 10", "Chouji - 10", "Nothing")) if("Bald") usr.removehair() usr.removehair() if("Gaara - 10") if(usr.Yen >= 10) usr.Yen -= 10 usr.removehair() var/obj/hairs/GaaraHair/a=new // you have to create the object in order to modify its icon :P usr.crgb(a)

 #4 Mar 22 2006, 11:31 am In response to Nintendo (#3) I did that, but that way I seem to be unable to remove it from the Overlays list...
 #5 Mar 22 2006, 11:36 am In response to Mysame (#4) Mysame wrote: I did that, but that way I seem to be unable to remove it from the Overlays list... When you add an object to overlays (not Overlays, BTW), only a copy of it is added to the list. To access that copy so you can remove it later, just set a var to the value of overlays[overlays.len] after you've added the obj to the list. Lummox JR
 #6 Mar 22 2006, 11:40 am In response to Lummox JR (#5) Lummox JR wrote: set a var to the value of overlays[overlays.len] after you've >added the obj to the list. Wait, so I should also figure in what position the object is added in? o.o; I'm quite confused here >.<
 #7 Mar 22 2006, 11:40 am In response to Mysame (#6) It is getting added to the end, so overlays.len would be the position it was added into.
 #8 Mar 22 2006, 11:41 am (Edited on Mar 22 2006, 11:56 am) In response to Papoose (#7) Ahh, true. Forget about that, lemme try. EDIT: Unnnggghhhhh. It works like a charm when added to 'overlays', there's just that minor drawback of 'overlays' resetting to 0 when update() is called... And adding to Overlays doesn't work, strangely enough..
 #9 Mar 22 2006, 1:47 pm In response to Mysame (#8) Mysame wrote: Ahh, true. Forget about that, lemme try. EDIT: Unnnggghhhhh. It works like a charm when added to 'overlays', there's just that minor drawback of 'overlays' resetting to 0 when update() is called... Then don't reset it in update(). And adding to Overlays doesn't work, strangely enough.. Maybe because there's no such var. Lummox JR
In response to Lummox JR (#9)
Well, it is defined mob/var/list/Overlays ... :|
Any advice here? Even adding usr.Overlays-='whateversuit.dmi' a dozen times doesn't help. Isn't there any way I could add the hair to Overlays?

EDIT:
 mob var/list/Overlays=list() proc/update() src.overlays=null for(var/i in src.Overlays)src.overlays+=imob barber icon='npcs.dmi' icon_state="woman2" layer=8 density=1 npc=1 DblClick() if(!(src in oview(1))) return 0 switch(input("What hair style would you like me to do for you today?")in list("Bald", "Gaara - 10", "Chouji - 10", "Nothing")) if("Bald") usr.removehair() if("Gaara - 10") if(usr.Yen >= 10) usr.Yen -= 10 usr.removehair() //var/obj/hairs/GaaraHair/a=new var/icon/i=new('hair_gaara.dmi') usr.hairaddress=i usr.crgb(i) else usr<<"You do not have enough money!" if("Chouji - 10") if(usr.Yen >= 10) usr.Yen -= 10 usr.removehair() //var/obj/hairs/ChoujiHair/a=new var/icon/i=new('hair_choji.dmi') usr.hairaddress=i usr.crgb(i) else usr<<"You do not have enough money!"mob/proc/crgb(icon/a) var/r=input(src,"How much red should the hair have? Between 0 and 255!") as num var/g=input(src,"How much green should the hair have? Between 0 and 255!") as num var/b=input(src,"How much blue should the hair have? Between 0 and 255!") as num if(r>255) r=255 if(r<0) r=0 if(g>255) g=255 if(g<0) g=0 if(b>255) b=255 if(b<0) b=0 a.icon+=rgb(r,g,b) src.Overlays+=a src.update()mob/proc/removehair() src.overlays.Remove(src.hairaddress) src.update()mob/var/hairaddress
 #11 Mar 23 2006, 1:56 pm In response to Mysame (#10) Mysame wrote: Well, it is defined mob/var/list/Overlays ... :| Dude, why would you create a var with the same name except for capitalization? There's a sure way to screw up your code. Ditch that list and use what else you learned in this thread to write code that makes sense. Lummox JR