ID:139883
 
Allo, So ive got my equip system working more or less using the code from Lummox Skin Guide 4 (for clothing etc) since its pretty much what i need it to do in a nutshell, i added a small modification onto it to handle things a little better to cater to my purposes.

Code: Entire object.dm code for debug purposes.
obj/iconholders
weapons
layer = FLOAT_LAYER-1

shirts
layer = FLOAT_LAYER-10
testshirt
icon = 'CShirt_Lightning.dmi'

headgear
layer = FLOAT_LAYER-10

pants

overalls
layer = FLOAT_LAYER-2
suit
icon = 'SuitBlack.dmi'
suit2
icon = 'CShirt_Lightning.dmi'


mob/proc/UpdateInventory()
var/items = 0
for(var/obj/items/O in src)
if(equipment && O.islot && equipment[O.islot]==O)
continue // don't show equipped items
winset(src, "inventory", "current-cell=[++items]")
src << output(O, "inventory")
winset(src, "inventory", "cells=[items]") // cut off any remaining cells


mob/proc/EquipGridder(var/type, var/grid)
var/list/Empty = list("overalls" = "D","shirt" = "Z") //this list is meant to output another object if the equip type is null as noted below.

if(isnull(equipment["[type]"]))
src << output(Empty["[type]"], "[grid]")
else
src << output(equipment["[type]"], "[grid]")

mob/proc/UpdateEquipment()
for(var/islot in equipment)
src.EquipGridder("overalls", "grid2")
src.EquipGridder("shirt", "grid1")


mob
proc/Equip(obj/items/O)
if(!O || !O.islot) return
if(equipment && equipment[O.islot])
Unequip(equipment[O.islot])
if(equipment && equipment[O.islot]) return // unequip failed
if(!equipment) equipment = new
equipment[O.islot] = O

src.overalls = O.refe //DBG -- want to get rid of this. and replace it with something like src.(type) = O.refe but i always get a bad index error.
// switch(O.islot) // the below commented out code works but i would like to avoid a large switch statement if possible.
// if("shirt")
// src.shirt = O.refe
// if("overalls")
// src.overalls = O.refe

src << "You equip [O]."
oview(src) << "[src] equips \a [O]."
Overlay_Build()
UpdateInventory()
UpdateEquipment()

proc/Unequip(obj/items/O)
if(!O || !O.islot) return
if(!equipment || equipment[O.islot]!=O) return // failed
equipment -= O.islot
if(!equipment.len) equipment = null // reclaim the list
src.overalls = 0 //DBG -- want to get rid of this
src << "You unequip [O]."
oview() << "[src] unequips \a [O]."
UpdateInventory()
UpdateEquipment()
Overlay_Build()

obj/items
var/islot // equipment islot
var/refe

verb/Get()
set src in oview(1)
if(src in oview(1)) // sanity check; the verb could come in late
loc = usr
usr << "You pick up [src]."
oview() << "[usr] picks up \a [src]."
usr.UpdateInventory()

verb/Drop()
set src in usr
if(src in usr) // sanity check; the verb could come in late
if(IsEquipped())
usr.Unequip(src)
if(IsEquipped()) return // unequip failed
loc = usr.loc
usr << "You drop [src]."
oview() << "[usr] drops \a [src]."
usr.UpdateInventory()

proc/IsEquipped()
if(islot)
var/mob/M = loc
if(ismob(M) && M.equipment && M.equipment[islot]==src)
return 1
return 0

verb/Equip()
if(islot) usr.Equip(src)

verb/Unequip()
if(islot) usr.Unequip(src)

clothing //Define Clothes
pants

shirts
testshirt
icon = 'CShirt_Lightning.dmi'
icon_state = "invent"
islot = "shirt"
refe = /obj/iconholders/shirts/testshirt

overalls
Suit
icon = 'SuitBlack.dmi'
icon_state = "invent"
islot = "overalls"
refe = /obj/iconholders/overalls/suit

Blug
icon = 'CShirt_Lightning.dmi'
icon_state = "invent"
islot = "shirt"
refe = /obj/iconholders/overalls/suit2


Problem description: I think i commented the right parts of the code for you guys.

So my question is how would i make mob variable change easily without a large switch statement thing (noted by the comment above in the equip proc) and my next question would be is there any other modifications that could be made to make this better?

I would use an associate list and say my_list[islot] = refe
In response to Pirion
well the thing is im trying to change the variables of the mob. in this case being either the shirt variable, overall etc. to that of the objects "refe" variable.

but yea
In response to Midgetbuster
mob
var
list/my_list = new()

obj
var
islot = "slot"
refe = "Reference"
my_obj/verb/user_verb()
var/mob/this_mob_we_want_to_change = usr
this_mob_we_want_to_change.my_list[src.islot] = refe

makes really no deference.
In response to Pirion
but that requires me to defining an entirely new list for whatever purpose you are trying to tell me.

Why would i need to define a new list as a mob list if i already have all the lists i want or need =\. i have inventory and equipment which is basically all i need for my purposes so there is no real need for a new list (to be saved in a save file mind you) to take up space.

not to mention that code totally and utterly not working to cater to the needs i clearly specified in the above post.
In response to Midgetbuster
Pirion's example does exactly what you want. If you are afraid of the List Boogeyman and have hangups about doing things in ways that make sense, then you can just use the vars list.
In response to Garthor
Sorry. Pirion and garthor.

I forgot to modify the overlay builder to accompany the change from player variables to list.

My bad indeed =\ maybe i should go back to sleep