ID:139488
 
Ok, so I have a list called items.. And on one thing when I pick up the knife it goes into my inventory and everything works fine. But, in my Die() proc, it won't remove the items.
EDIT: Well, it actually WILL remove the item, but the verbs will stay x.x
Err.. Let me show you the code..
My knife:
obj
Knife
name="Knife"
icon='Icons.dmi'
icon_state="Knife"
verb
PickUp()
set name="Pick up"
set src in oview(1)
src.loc=null
var/obj/Knife/P = new(usr)
usr.items.Add(P)
Drop()
src.loc=usr.loc
var/obj/Knife/P = locate(/obj/Knife) in usr.items
P.name="Knife"
P.icon_state="[P.name]"
usr.items-=P
Equip()
if(usr.equiped)
return
else
usr.equiped=1
var/obj/Knife/P = locate(/obj/Knife) in usr.items
usr.equip="[P.name]"
P.icon_state="[P.name]E"
P.name="<font color=red>[P.name]</font>"
usr.underlays+=P
return
UnEquip()
set name="Unequip"
if(!usr.equiped)
return
else
usr.equiped=0
usr.equip=""
var/obj/Knife/P = locate(/obj/Knife) in usr.items
P.name="Knife"
P.icon_state="[P.name]"
usr.underlays-=P
return

Everything works for the knife, drop works, pick up works, etc.

My Die() proc:
mob/proc/Die()
var/mob/DeadIcon/A = new/mob/DeadIcon(loc, src)
A.loc = src.loc
A.icon=src.icon
A.icon_state="Dead"
A.name2="[src.name]"
A.name="[src.name]'s Corpse"
A.realname="[src.realname]"
A.died=1
src.name=src.key
A.playername="[src.name]"
src.invisibility=1
src.see_invisible=1
src.Type="Spectator"
src.icon='Ghost.dmi'
src.Spectator=1
src.layer=999
src.verbs += typesof(/mob/Spectator/verb)
src.density=0
src.loc=locate(35,35,1)
src.name="[src.key]"
src.Joined=0
src.slot=0
src.slot2=0
src.verbs -= typesof(/mob/Player/verb)
src.firstname=""
src.lastname=""
src.realname=""
src.Mute=0
src.died=1
src.equiped=0
src.equip=""
src.items.Cut()
src.underlays.Cut()
global.allplayers.Add(A)
global.players-=src
global.players+=A
global.nonplayers+=src
global.dead++
if(global.dead>=global.Players)
world.GameEnd()
return
winset(src,"child1","left=window3")
return


It has src.underlays.Cut() which works, and src.items.Cut().. Which doesn't. I also tried defining Knife as var P and doing src.items-=P, but that didn't work either..

Help would be appreciated.. Thanks in advance.
Because you aren't doing anything to contents, which is where the actual knife is stored. items should be completely ancillary to the contents list, only holding pointers to the items that are in your contents for the sake of ease of use, and so you should create setter functions to modify both contents and items at the same time. For example:

mob/proc
add_item(var/obj/O)
contents += O
items += O
remove_item(var/obj/O)
contents -= O
items -= O


Your PickUp() and Drop() procs are particularly screwing things up, because you are creating new objs to add to items for some reason, instead of just using src. Placing objects in a list will not relocate them except for the single special case of the contents list, so there's no need to do that.
In response to Garthor
Thank you!