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.
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:
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.