ID:2846303
 
(See the best response by Albro1.)
So I've got a simple for-loop to find all instances of an object and assign it an ID number for cross referencing purposes later, but I've noticed the object in the lowest left gets a number, then the one to its right, then when there's no more to the right it goes up and does that part next.

Is there any way to control the search pattern at all? Couldn't see anything about it in the F1, so I'm assuming no, but thought it wouldn't hurt to ask.

If not, I guess I'll try adding each object to a list, check its co-ords and remove it if it's the next in the order I wanna do :)

Any help appreciated! Let me know if you need more info or if I didn't explain this clearly enough! (I'm not great with figuring out the correct terminology lol)
Best response
If you run a quick test like this you can see what sort of behavior DM will consistently use when looping through objects in the world:
mob/verb/checkloop()
for(var/turf/t in world)
usr << "[t.x],[t.y]"


This outputs the coordinates of every turf in the world, starting at 1,1 -
then going all the way up to world.maxx,1 -
then going to 1,2 and continuing.

With that in mind you can know that the objects in your list will be placed in the same order, and you can adjust the list as needed with that knowledge.
Ooh, perfect, thank you :)
How long do the IDs need to remain stable for? There is always the chance that BYOND will update and change the map load order.
The IDs remain the same throughout the world's savefile, but are assigned when the world is created (it's part of my worldgen) so uh, forever? I guess? If byond updated in such a way, I'd just have to rewrite it. Writing a proc specifically to do this in the order I'd prefer feels a bit like overengineering, tbh

(especially when it's perfectly serviceable in the order it normally does the loop in right now, I'm just a picky git and want the object in the most top-left to have the lowest number and the one in the most bottom-right to have the highest lol)