ID:139819
 
I tried searching the forums, but I couldn't find my solution.
Here is my code:

mob/proc/Overlay_Refresh()
src.overlays = src.Overlays


obj
var
slot
skill=0
equipped=0
Shinigami_Items
Sword
icon='Icons/Items.dmi'
IS="sword"
name="Asauchi"
Click()
if(src in usr)
if(!src.equipped && !(usr.Equipped[SWORD]))
src.equipped=1
usr.equipment+=src
usr.Equipped[SWORD]=1
var/obj/O = /obj/Shinigami_Items/Asauchi
usr.Overlays["Sword"]=O
usr.Overlay_Refresh()
src.suffix = "Equipped"
//usr.UpdateEquipment()
//usr.UpdateInventory()
else if(src.equipped&&usr.Equipped[SWORD])
src.equipped=0
usr.equipment-=src
usr.Equipped[SWORD]=0
usr.Overlays["Sword"]=null
usr.Overlay_Refresh()
src.suffix=""
//usr.UpdateEquipment()
//usr.UpdateInventory()
Asauchi
icon='Icons/Sword.dmi'
layer=MOB_LAYER+1

And I get this error message in-game:
runtime error: bad index
proc name: Click (/obj/Shinigami_Items/Sword/Click)
usr: Chris (/mob/player)
src: Asauchi (/obj/Shinigami_Items/Sword)
call stack:
Asauchi (/obj/Shinigami_Items/Sword): Click("Inv", "statspane.info1", "icon-x=69;icon-y=17;left=1")


Can anyone help me? I am just trying to simply overlay a sword. But I am trying to use an associative list so I can manage my overlays later.(Saw this multiple times in my search)

From what i can gather from that your equip system uses slots defined by "IS"?

then you do a common mistake by making equipped in the actual item itself

i dont know if this will help you at all or not but ill give you a direct rip from my game and see if that helps you at all.

mob
proc/Equip(items/O)
if(!O || !O.islot) return
if(equipment && equipment[O.islot])
Unequip(equipment[O.islot])
if(equipment && equipment[O.islot]) return
if(!equipment) equipment = new
equipment[O.islot] = O
src.equipped[O.islot] = O.refe
src.equipped["[O.islot]c"] = O.colour
src << output("You equip <font color = [RarityList["[O.rarity]"]]>[O]</font>.","balog")
UpdateInventory()
UpdateEquipment()
Build_Icons()

proc/Unequip(items/O)
if(!O || !O.islot) return
if(!equipment || equipment[O.islot]!=O) return
equipment -= O.islot
if(!equipment.len) equipment = null
src.equipped -= O.islot
src.equipped -= "[O.islot]c"
src << output("You unequip <font color = [RarityList["[O.rarity]"]]>[O]</font>.","balog")
UpdateInventory()
UpdateEquipment()
Build_Icons()

items
(bla set parent type to obj in the right indent)
proc
IsEquipped()
if(islot)
var/mob/M = loc
if(ismob(M) && M.equipment && M.equipment[islot] == src)
return 1
return 0


items
Clothing
Use()
set hidden = 1
if(src in usr)
if(IsReq())
if(IsEquipped())
usr.Unequip(src)
else
usr.Equip(src)
else
usr << output("cannot equip message", "balog")

Click()
Use()
In response to Midgetbuster
No, IS is the icon_state.

#define IS icon_state
In response to Albro1
That is one the absolute worst uses of the #define macro I've ever seen, by the way.
In response to Albro1
arr.

Well then the :slot: you mentioned is changed in my code to islot (item slot)
In response to Garthor
Garthor wrote:
That is one the absolute worst uses of the #define macro I've ever seen, by the way.

What is wrong with it? It is a matter of preference.
In response to Albro1
Because it REDUCES clarity for little-to-no actual gain.
In response to Garthor
Well, I do understand that it would not be very clear for the community, but as I said, it is a matter of preference. I will be sure to change it whenever I have to post code, but I like it this way in my code.
since i have no other ways to contact you atm(msn wont work on my phone for some odd reason and the only places i can post using my phone on byond are forums o-o). my laptop had some hardware problems and is no longer working, so im currently in the process of trying to get another on which I'll be getting soon :). anyway you my not see me on for a short while :P.
In response to Masschaos100
Damn...right when I needed you...Well, go to my site's forums next time so we don't derail topics or bring up old ones :P