ID:139273
 
Code:
obj

verb/Pick_Up()
set src in oview(1)
var/I = usr.contents
src.Move(I)
del(src)

/*
runtime error: undefined proc or verb /list/Enter().

proc name: Pick Up (/obj/verb/Pick_Up)
usr: Guest-2623295115 (/mob)
src: the broad sword (/obj/broad_sword)
call stack:
the broad sword (/obj/broad_sword): Pick Up()
*/


Problem description: Please could someone help me with this. Got a runtime error and not sure why

You're not doing that correctly. With what you have there, you've assigned usr.contents, which is a list, to a regular variable (which you shouldn't do anyway) then tried to move src into it.

Adding items to your contents is easily done like this:

obj
verb
Pick_Up()
set src in oview(1)
src.loc = usr //move src, the obj, into usr, which automatically adds it to the usr's contents.


This is a very simple way to move an existing objects into the usr's contents.
In response to Pyro_dragons
Oh ok I see. I thought I had to define that the lost belongs to the usr. Thanks alot

Also how would I define the pick up using a Click()?
So far I have this:
obj
Click()
switch(alert("What would you like to do?",,"Pick Up"))
if("Pick Up")
set src in oview(1)
src.loc = usr
usr << "You got [src]"
del(src)
In response to Saladon
Don't delete src. That gets rid of it. When you change the loc to usr, it automatically moves the whole obj into the contents list. It won't be on the ground anymore. You may also want to check and make sure that you can't pick up an item you already have.

IE if(src.loc == usr) return
X.contents is a list which, by definition, contains all the objects which are located within X. However, it is not LITERALLY X, and therefore an invalid target to relocate something to.

Instead of (essentially) src.Move(usr.contents), you need to do src.Move(usr).

src.loc = usr would also get the job done, but using Move() will add some helpful utility, like calling Enter() and Entered() and such.

Also: don't delete src after moving it. Otherwise you... delete it after moving it. And so it's gone.