/obj/inventory
StarterShirt
name = "Blue Shirt"
icon = 'icons/player/blueshirt.dmi'
var/worn = 0
density = 0
Click()
if(src in usr.contents)
if(src.worn)
src.worn = 0
usr << "You remove the [src.name]."
usr.overlays -= 'icons/player/blueshirt.dmi'
src.suffix = ""
else
src.worn = 1
usr.overlays += 'icons/player/blueshirt.dmi'
usr << "You wear the [src.name]."
src.suffix += "{-Equipped-}"
verb/Drop()
set category=null
if(src:worn == 1)
usr << "Not while its being worn."
else
del(src)
verb/Get()
set src in oview(1)
Move(usr)
view(3)<<"[usr] picks up [src.name]."
/obj/inventory
StarterPants
name = "Black Pants"
icon = 'icons/player/pants.dmi'
var/worn = 0
density = 0
Click()
if(src in usr.contents)
if(src.worn)
src.worn = 0
var/custom = 'icons/player/pants.dmi'
custom += rgb(src.customred,src.customgreen,src.customblue)
usr.overlays -= custom
usr.overlays -= 'icons/player/pants.dmi'
usr << "You remove the [src.name]."
src.suffix = ""
else
src.worn = 1
usr.overlays += 'icons/player/pants.dmi'
usr << "You wear the [src.name]."
src.suffix += "{-Equipped-}"
verb/Drop()
set category=null
if(src:worn == 1)
usr << "Not while its being worn."
else
del(src)
verb/Get()
set src in oview(1)
Move(usr)
view(3)<<"[usr] picks up [src.name]."
Problem description:
how would i make i t so i can shorten these into a simple tree? and so i can add on items without having huge unnecessary lines of code like this. thank you for your time :D. i havent coded in a long time therefore im rusty.
Embedding common behavior in root types is what you want to do. If you find yourself repeating code over and over again, it's probably because you missed the opportunity to create a common type somewhere along the way.
With all that done, you can just derive from the equipment type by variation:
Polymorphic overrides can change as little or as much structure as you want, and can introduce all kinds of new behavior or structure if you want --or not.
Cheers!