ID:180462
 
I'm trying to make a command so that when a player selects an object, it copies that object and moves the copy to the players inventory. The problem is, when I try something like:

O = new(src)

I end up with an object called 'obj', which isn't quite what I was hoping for.

Does anyone know how to do this properly?
im not sure exactley what you could do

but you could do this
make a obj template
put this code anywhere in your code...

obj
var
locationname
Click()
usr.contents += new locationname

and for the obj that you are trying to copy, put this in under it

obj
exampleobject
locationname = /obj/exampleobject

if you had a apple, it would look like this

obj
apple
locationname = /obj/apple

the reason this works, is cuz the template tells all obj's that when you click on it, to do the click action, which is to add the variable called "locationname" to the user's contents, and the variable called "locationname" is defined in each obj, and it tells it that it is a obj

if you wanted to make a seperate section for obj's that can be copied, and leave the rest so they cant be copied, just use this template instead

obj/copyable
var
locationname
Click()
usr.contents += new locationname

and use this for the obj's that can be copied list them like this...

obj/copyable
apple
locationname = /obj/copyable/apple

for multiple obj's do this...

obj/copyable
apple
locationname = /obj/copyable/apple
pork
locationname = /obj/copyable/pork
rootbeer
locationname = /obj/copyable/pork

this works cuz the obj/copyable template says that every obj listed in the obj/copyable "directory"(<< dont know if that is what i should call it) has a click proc. and when you click it, it finds the locationname var that we defined in each one, then adds it to the users contents

note that this will copy that obj into the contents each time you click it

hopefully i have helped,
<font color=red><x><</x></font><font color=orange><x>^</x></font><font color=yellow><x>></x></font><font color=darkred>F</font><font color=red>I</font><font color=orange>R</font><font color=yellow>E</font><font color=yellow>K</font><font color=orange>I</font><font color=red>N</font><font color=darkred>G</font><font color=yellow><x><</x></font><font color=orange><x>^</x></font><font color=red><x>></x></font>
On 6/7/01 9:37 pm Foomer wrote:
I'm trying to make a command so that when a player selects an object, it copies that object and moves the copy to the players inventory. The problem is, when I try something like:

O = new(src)

I end up with an object called 'obj', which isn't quite what I was hoping for.

Does anyone know how to do this properly?

O = new src.type(usr) // make a new object in usr.contents of the same type as src

I think that will do the trick. You might want to go through all the important variables and set them equivilent to the src variables.
In response to Shadowdarke
On 6/8/01 8:33 am Shadowdarke wrote:
On 6/7/01 9:37 pm Foomer wrote:
I'm trying to make a command so that when a player selects an object, it copies that object and moves the copy to the players inventory. The problem is, when I try something like:

O = new(src)

I end up with an object called 'obj', which isn't quite what I was hoping for.

Does anyone know how to do this properly?

O = new src.type(usr) // make a new object in usr.contents of the same type as src

I think that will do the trick. You might want to go through all the important variables and set them equivilent to the src variables.

Yeah, that's exactly what I needed. Thanks!
In response to FIREking
all that crap for nothing
damnit !!!!!!!!
FIREking