ID:171084
 
The problem is this: I need to find out the names of each thing that is derived from, eg, /turf/buildable
Sgeo wrote:
The problem is this: I need to find out the names of each thing that is derived from, eg, /turf/buildable

I remember having the same question when making Bunniflip. I suppose you want to do it at runtime, then you could make a temporary object from a path list, and put that name in a list. Here's an example:
var/turf/T = locate(1,1,1)  // Save the first turf
var/oldtype = T.type // And its type
var/list/namelist = new()
for(var/turftype in typesof(/turf/buildable)-/turf/buildable) // Loop through all turfs
var/turf/buildable/B = new turftype(locate(1,1,1))
namelist[B.name] = B.type // And make an associated list of them.
new oldtype(locate(1,1,1)) // Restore the first turf.


This is kind of hacky since you need to do actions on a turf (in my example, the one at (1,1,1)), so if you have tags or other important things set on this turf, it could be a problem. Hopefully you haven't. :)

The result, if you're not familiar with associated lists, is a list which can be used in input procs such as this:
var/build = input(src,"Choose thing to build") as null|anything in namelist

if(build)
var/turf = namelist[build]
new turf(src.loc)


Good luck!

/Gazoot
In response to Gazoot
Thanks :-). In case you were wondering, this is being used in byond://Sgeo.Build