ID:147960
 
I'm having problem creating objects in src.loc...

Here's what I have, but It's not working... It doesn't appear in the location the src is in.

mob/proc/create_disk()
new /obj/disk/mm in src.loc

Nothing appears there, though.
Can anyone give me a hand?
mob/proc/create_disk()
new /obj/disk/mm (src.loc)

In response to Unknown Person
Thank you, it worked. But I'd like to know why mine didn't work. Just wondering, so I can learn from my mistakes.

mob/proc/create_disk()
new /obj/disk/mm (src.loc) //yours

new /obj/disk/mm in src.loc //mine
In response to Rocker121
ok, the problem with yours is, when using the new proc, you use the following syntax:

new TYPE (location)

TYPE is the new objects type
location... well, self explanitory.

You were not using the correct syntax, you could have done this though:
var/obj/newobj = new /obj/disk/mm ()
newobj.loc = location
(replace location, with where to put it)
In response to Rocker121
The "in" operator is only used to check if something is in a list, or in the contents of an atom. So if M is a mob and T is a turf, then (M in T) will return true if M is "standing on" T. (Atoms that are on turfs are considered to be "inside" those turfs.) If O was an obj in M's inventory, then (O in M) would also be true.

All of that was a roundabout way of saying that "in" isn't used in new() statements.
In response to Crispy
mob/proc/create_disk()
new/obj/disk/mm(locate(usr.x,usr.y,usr.z))
In response to Buzzyboy
Buzzyboy wrote:
new/obj/disk/mm(locate(usr.x,usr.y,usr.z))

That's identical to <code>new/obj/disk/mm(usr.loc)</code>, but requires more effort. The reason being: <code>usr.loc==locate(usr.x,usr.y,usr.z)</code>
In response to Crispy
Your'e wrong crispy, it's much different. It's actually a lot safer when you use it like I do. Sometimes it will do nothing. So it's best to use my way.
In response to Buzzyboy
Your'e wrong crispy, it's much different.

Yep it is different.

It's actually a lot safer when you use it like I do.
Uhh no. It's only slower.

Sometimes it will do nothing.

If it does nothing one way it will do nothing the other way since both methods will essentially do the same thing except when you call locate you're adding on some extra work.

Calling locate(usr.x,usr.y,usr.z) will return usr.loc except in one exception. So by using locate(usr.x,usr.y,usr.z) instead of usr.loc you're only adding one step.

The only exception is if usr.loc isn't a turf(ie the usr in in someones contents or is in an area(text mud type of thing). In this case usr.loc != locate(usr.x,usr.y,usr.z) but it is the only case.

If it does nothing sometimes and it isn't from this exception then you should post the offending code in bug reports since it is a bug(or just plain old programmer error).