obj
building
var/multi_build = 0 // value > 0 if the central obj of the building
var/obj/building/list/building_controller[]
core
multi_build = 1 // how large the building might be
world/New()
..()
spawn(10) // post-world creation building assignment
for (var/obj/building/A in world)
if (A.multi_build > 0)
var/obj/building/list/new_building[] = new()
var/obj/building/list/buildings_in_range = range(A, A.multi_build)
for (var/obj/building/B in buildings_in_range)
new_building += B
for (var/obj/building/B in buildings_in_range)
B.building_controller = new_building
Problem description:
I'm trying to build multi-object buildings. I place down a /obj/building/core and surround it with /obj/building to make a 3x3 building. I can currently create a var/obj/building/list/building_controller[] no problem, and assign that list as a reference to all the /obj/building parts of the building.
However, I want to make a database of building_controllers, so I can access information from one (assumedly global?) location. I'm essentially trying to make a list of a list, which could vary in size.
I've tried using 2d lists but always struggle with merging 1d lists into it (building_controller). I think what I need is a "jagged list" but I don't know how to create/use one in BYOND, or whether there's a better alternative.
Rather than just truck on and find something that _does_ work, I'm more interested in finding the best way to work this.
Thankyou for your time!
Now, personally I'd make these "building controllers" actual datums, but whatever.