ID:1671717
 
proc/locate_all(tag)
. = list()
var datum/found
do
found = locate(tag)
if(found)
found.tag = null
. += found
while(found)
for(found in .) found.tag = tag

Returns a list of all datums with the given tag.

I used this to let a single switch on the map to unlock multiple doors.

e.g.:
/*

You would set up your doors and buttons on the map using the instance editor.
Edit a door instance and set its "tag" variable to some text identifier.
Then, make sure the button has its door_tag equal to the door's tag.
Normally, you would only be able to use one unique tag per door.
With locate_all(), tags no longer have to be unique.

*/

obj/button
var door_tag

Crossed(mob/M)
if(istype(M) && M.client)
for(var/obj/door/door in locate_all(door_tag))
door.Unlock()
loc = null
Quick question, what might be a possible value of door_tag?
In response to Zecronious
Any string, just like tag.
Great code, expert stuff.

The only possible thing I have to add is so incredibly small it's ridiculous and insanely nit picky but I feel compelled.

There's a line where you say:
found.tag = ""


After learning more about tags this begged the question. Would this run faster?
found.tag = null


Turns out that I consistently shave off a ridiculously small amount of time.


Which makes sense because setting something to null is easier than making an empty string.

Dunno what you'll be able to spend all that time on now that you're freed up and all, but you have been visited by your local nit picker. Have a great day.