ID:138773
 
Code:
var/global/obj/light/Light



obj/Giver/
icon = 'torchmaker.dmi'
verb
Make_Item()
set src = view(1)
giver_loop:
var/obj/o
for(o in world)
if(o == Light) continue giver_loop
for(o in world)
view(5) << "[usr] gets (a/an) [o]!"
o.loc = usr.loc


Problem description:
Ok, I'm fairly new to coding and I was reading through the guide. It got me thinking so I tried to create an item that allows me to make a copy of any item within the world. The compiler says it's fine, but whenever I try to use the object, I get a runtime error stating:

runtime error: Cannot modify null.loc.
proc name: Make Item (/obj/Giver/verb/Make_Item)
usr: the pppgggr (/mob/DM)
src: Giver (/obj/Giver)
call stack:
Giver (/obj/Giver): Make Item()

Where am I modifying something set to null? am I going about this incorrectly? I got the basis for the code form the guide and added a few edits to it myself. I'm not even half-way through the guide, so there's a huge chance that I'm making this more complicated then it should be.
What exactly are you trying to do? You should avoid using anything like "giver_loop:"

I've never even seen continue used that way. You're using continue like you'd use goto. Avoid using goto, that's only useful in Assembly language. continue is for going to the next step in a loop. If you're making an obj there is no reason to loop through every object in the world. Also, when using set src do set src in view(1).

Are you trying to duplicate an item that you're standing near? You would do something like:

    verb
Make_Item()
set src in view(1)
var/obj/o = new src.type
o.loc = usr.loc//or o.loc = locate(usr.x, usr.y, usr.z


If you want it to be in the usr's contents change usr.loc to usr. I haven't tested any of this out because I have to head out shortly. I hope I've pointed you in the right direction. If you have any questions feel free to reply.
In response to Zaltron
Not what I want. What I want is to pick any object currently in the world(Besides the one that I had it skip over, thus the "Continue") and have it appear on the ground at my feet.
In response to Pppgggr
Try this:

obj/Giver/
icon = 'torchmaker.dmi'
verb
Make_Item()
set src in view(1)
var/list/L = list()
for(var/obj/o in world)
if(o == Light)continue
L += o
var/obj/o = input(usr, "What obj would you like to create?", "Duplicate an obj in the world") in L
var/obj/new_obj = new o.type
new_obj.loc = locate(usr.x, usr.y, usr.z)
In response to Zaltron
It worked in ever aspect except in the fact that it didn't skip over the Light, as I was trying to do. Ill mess with it a bit.
In response to Pppgggr
I don't think you have that part set up right. What exactly are you trying to do with the "Light" part?
In response to Zaltron
Light's a variable set to a specific object. I don't want that object to show up in the list.
In response to Pppgggr
var/list/objwithoutlight=list()
for(var/obj/o in world)
if(!o.Light) objwithoutlight.Add(o)