ID:927926
 
Code:
        Equip(obj/Equipment/I, mob/Z)
if(I.dReduction > 0) Z.DamageReduction+=I.dReduction
if(I.dRpen > 0) Z.DRPEN+=I.dRpen
I.dEquip = 1
mb_msgout("You equip [I.dName] on your [getSlot(I)]!", Z)
mb_msgout("[Z.name] equips [I.dName] on their [getSlot(I)]!", oview(0, Z))
Z.equipment.Add(I[I.dSlot])
Z.inventory.Remove(I)


Remove(obj/Equipment/I, mob/Z)
if(I.dReduction > 0) Z.DamageReduction-=dReduction
if(I.dRpen > 0) Z.DRPEN-=dRpen
I.dEquip = 0
mb_msgout("You equip [I.dName] on your [getSlot(I)]!", Z)
mb_msgout("[Z.name] removes [I.dName] from their [getSlot(I)]!", oview(0, Z))
Z.equipment.Remove(I[I.dSlot])
Z.inventory.Add(I)


Problem description:

Basically i'm trying to index the items index in the equipment list by a # a max of 10 objects the item i try to wear has a dSlot of 1 so it should goto the first index? but it doesnt it just throws a list out of bounds error.

Error
runtime error: list index out of bounds
proc name: Equip (/obj/Equipment/proc/Equip)
source file: EquipmentSystem.dm,44
usr: ThunderZ (/mob/Player/saiyan)
src: RetardHat (/obj/Equipment/RetardHat)
call stack:
RetardHat (/obj/Equipment/RetardHat): Equip(RetardHat (/obj/Equipment/RetardHat), ThunderZ (/mob/Player/saiyan))
/Command/testwear (/Command/testwear): Process(ThunderZ (/mob/Player/saiyan), RetardHat (/obj/Equipment/RetardHat))
/Parser (/Parser): Process(ThunderZ (/mob/Player/saiyan), /Command/testwear (/Command/testwear), /list (/list))
/Parser (/Parser): Parse("testwear retard", ThunderZ (/mob/Player/saiyan))
Telnet @127.000.000.001 (/client): Command("testwear retard")
Z.equipment.Add(I[I.dSlot])


This line is your problem. You are accessing the equipment object as a list. It is not a list, therefore, you are getting an error.

Z.equipment[I.dSlot] = I


That's what you meant.
Okay that worked but one last question

I'm trying to show a name of an item from a variable how can i do it?

Currently it just shows the objects code name

            mb_msgout("---------------------------", user)
mb_msgout("| {REQUIPMENT{x |", user)
mb_msgout("---------------------------", user)
mb_msgout(" Head: [user.equipment[1]]", user)
mb_msgout(" Eye: [user.equipment[2]]", user)
mb_msgout(" Ear: [user.equipment[3]]", user)
mb_msgout(" Neck: [user.equipment[4]]", user)
mb_msgout(" Chest: [user.equipment[5]]", user)
mb_msgout(" Wrists: [user.equipment[6]]", user)
mb_msgout(" Gloves: [user.equipment[7]]", user)
mb_msgout(" Finger: [user.equipment[8]]", user)
mb_msgout(" Pants: [user.equipment[9]]", user)
mb_msgout(" Boots: [user.equipment[10]]", user)
mb_msgout("---------------------------", user)
There are a few ways you can do this:
var/obj/o = user.equipment[1]
mb_msgout(" Herp: [o.name]",user)


or:

mb_msgout(" Herp: [user.equipment[1]:name]",user)


My favorite:

mb_msgout(" Herp: [user.equipment.len>=1&&user.equipment[1]!=null ? user.equipment[1]:name : "empty"]")


Might be a syntax error in there somewhere, let me know if you have troubles.
I tried

            mb_msgout("  Head: [user.equipment[1]:dName]", user)
mb_msgout(" Eye: [user.equipment[2]:dName]", user)
mb_msgout(" Ear: [user.equipment[3]:dName]", user)
mb_msgout(" Neck: [user.equipment[4]:dName]", user)
mb_msgout(" Chest: [user.equipment[5]:dName]", user)
mb_msgout(" Wrists: [user.equipment[6]:dName]", user)
mb_msgout(" Gloves: [user.equipment[7]:dName]", user)
mb_msgout(" Finger: [user.equipment[8]:dName]", user)
mb_msgout(" Pants: [user.equipment[9]:dName]", user)
mb_msgout(" Boots: [user.equipment[10]:dName]", user)


it just gives

CODE\ZCommands.dm:524:error: bad embedded expression [user.equipment[1]]
CODE\ZCommands.dm:525:error: bad embedded expression [user.equipment[2]]
CODE\ZCommands.dm:526:error: bad embedded expression [user.equipment[3]]
CODE\ZCommands.dm:527:error: bad embedded expression [user.equipment[4]]
CODE\ZCommands.dm:528:error: bad embedded expression [user.equipment[5]]
CODE\ZCommands.dm:529:error: bad embedded expression [user.equipment[6]]
CODE\ZCommands.dm:530:error: bad embedded expression [user.equipment[7]]
CODE\ZCommands.dm:531:error: bad embedded expression [user.equipment[8]]
CODE\ZCommands.dm:532:error: bad embedded expression [user.equipment[9]]
CODE\ZCommands.dm:533:error: bad embedded expression [user.equipment[10]]
Ah, that right, my bad, I'm thinking another syntax. I work with a few languages that allow runtime accessors, so I occasionally mix up which ones can do what. (This sometimes happens when you know a dozen or more programming languages)

Yeah, my bad.

Go with the first example, then.

var/obj/o = user.equipment[1]
mb_msgout("herp [o.name]",user)
o = user.equipment[2]
mb_msgout("derp [o.name]",user)


You know, in this case, I'd actually do an associative list:

Set up your equipment to use strings instead of slot numbers. That way, you can do this:

for(var/v in user.equipment)
var/obj/o = user.equipment[v]
mb_msgout(" \proper[v] [o.name]", user")


When you set up an item's equipment:

obj/item/equipment
var
slot = "head"


When you assign it:

equipment[I.slot] = I


These are called associative lists. You essentially give each index in an array a name, and the name can be referenced like an index to get an assigned value. In other languages these are called HashMaps.
I see now.

I got it working thanks.