ID:273685
 
I know how to make an object that can be looted and has a variable for the loot and I know how to make a verb trigger when a player presses L but I don't know how to make my verb search for the corpses.

Object Info :
There will be many types of corpses so I need a verb that can recognize any type under /obj/Corpse.

obj/Corpse
icon = 'Corpse.dmi'
Human_Corpse
icon_state = "Human Corpse"
var
Loot = "Sword"


Verb :

mob
verb
Loot()
var/Corpse = locate(/obj/Corpse/ in oview(0))
if(Corpse)
usr << "You found a [Corpse.Loot]"
etc etc etc


Alright so I'm this far but apparently Corpse.Loot is undefined... How can I get this to recognize the corpses and allow me to access the loot variable? Oh and I know you can use Byond's in built object functions for a typical boring inventory but I'd like something different so I'm doing it this way.

Thank you.
You did not specify the type of the Corpse variable, so the compiler does not allow you to access members of the obj/Corpse/Human_Corpse type. So, you'd need to declare the variable as var/obj/Corpse/Corpse, and you would also need to move the Loot variable to that type, as otherwise it's incredibly impractical.

Additionally, your syntax for locate() is wrong. You want locate(type) in list, not locate(type in list).
In response to Garthor (#1)
I kinda get what you're saying but this says it's undefined as well :

    verb
Loot()
var/obj/Corpse/Corpse = locate(/obj/Corpse) in oview(0)
if(Corpse)
usr << "You found a [Corpse.Loot]"


What am I doing wrong?
In response to Kyle_ZX (#2)
You've defined obj/Corpse/Human_Corpse/var/Loot, but not obj/Corpse/var/Loot. You need to move the definition of the Loot variable to the Corpse type.
In response to Garthor (#3)
Thank you, I finally get it... That was so silly of me.