ID:321977
 
(See the best response by DarkCampainger.)
Code:
weapon
parent_type = /obj/grab
verb
equip()
set src in view(-1)
set name = "Equip"
for(src in usr.overlay) return // overlay is a list ah usr's overlays
src.layer = MOB_LAYER + 0.5
usr.overlay += src
usr.overlays += src
usr << "[src] equipped."


Problem description:
In runtime, it returns a error saying: "Cannot read null.layer".

I should have waited more before asking you guys, but now I know you are so smart and so helpful...
I can't get used to this.
Best response
I think your for(src in usr.overlay) line is setting src to null, so when you later try to use it, it's invalid.

What are you trying to do with that line? Prevent the user from equipping an item twice? You should just be able to use an if():
if(src in usr.overlay) return // overlay is a list ah usr's overlays

But I've got to mention, naming a variable "overlay" is very confusing. Why not "equipment" or something?
It's working now. I follow your advice and change de name of the overlay var. Thanks again DC!