ID:138727
 
Code:
obj
var/Obj_id
New()
.=..()
Obj_id=Create_UID()
proc/GetPerfObjs()
for(var/obj/O in world)
for(var/A in O.PerfobjList)
SRMList.Add("[A];[O.Obj_id]")


Problem description:
I need a list of Perfobjs contained within each object in the world. I then need to save these Perfobjs with an ID that can be referenced to find the object it came from.

For some reason, my world crashes when I try to use the above code. Thinking searching every object in the world is causing the crash, but I can't think of any more efficient way to do it. The Perfobjs in each object change rather often, and each time the story-engine is run actually..

Edit: Sorry if I posted this in a bad way, or in the wrong sub-forum. I usually try to fix my problems myself, but I've been stuck on this for three days because the engine requires it to move forward...
Do you have many objects in your world? And do you need this proc to be run and finished instantly? If not, consider putting a small sleep delay (Even something like sleep(0.1) will help)
In response to Jin150
There are only 1028 objects in the world. I can do an object count with no problem, strangely enough.
verb/Countobjs()
var/Am
for(var/obj/O in world)
Am++
world<<"Objects in world: [Am]"


:/
I'd recommend finding exactly the point at which it crashes, using something like the below:

obj
var/OBJ_id
New()
.=..()
OBJ_id=Create_UID()
proc/GetPerfObjs()
world<<"Off we go"
for(var/obj/O in world)
world<<"At: [O], [O.name]"
sleep(1)
for(var/A in O.PerfobjList)
world<<"With: [A], [A.name]" //Assuming this is appropriate
sleep(1)
SRMList.Add["[A];[O.Obj_id]"]

Try that, see what the outcome is. Is there any specific object it's crashing at?
In response to El Wookie
That helped pinpoint what's causing the crash. It has nothing to do with the main part of the proc, it seems.

A is blank for some reason(object is a tree, meaning there should atleast the 'cut' prefobj on the list. It shouldn't come out blank. There's even a 'void' prefobj that every object has until said prefobj is replaced..), and the world crashes(white screens the process, locks up Dream Seeker/Dream Daemon) when it tries to append "[A];[O.Obj_id]"(should end up being ";[a042]", due to A being blank) to SRMList...
In response to Medicator
Might I suggest trying

         for(A as anything in O.PerfobjList)


to see if A is still null that way?
In response to Valekor
Thank you!! That actually worked, and fixed the crashing as well. Shouldn't (var/X in list) get anything in the list, though? Anyways, thanks again~

Edit: You gave me the idea of changing the perfobjs loaded into an object's PerfobjList to a different type(Text), and it seems to work as it was. perfobj being an obj doesn't seem to work unless I define type as 'anything'.
In response to Medicator
Glad I could help. :)

I thought so too, but I've encountered this problem before. Maybe
 var/x in list

treats the variable as text, and if it is a specific type like an object, you'd need to define it as : (?)
 var/obj/x in list


I'm kind of clueless as to the actual reason why though.
Maybe someone else could be so kind as to explain why?