Problem description: I have var/x = "object1" and I want to create an object like this, based on the value of x, var/obj/object1/y = new/obj/object1(), I could use ofc:
if (x == "object1")
var/obj/object1/y = new/obj/object1()
else if (x == "objext2")
var/obj/object2/y = new/obj/object2()
And keep going but thing is I have like 1000 objects and the if-else-if lines would be huge. Is there any more fast way?
The easiest, but least-safe way, is to use text2path():
A safer way would be to not use text2path(), but provide an associative list to choose from:
Only thing you can't do is declare variables using a variable type. You'll have to use the "greatest common factor" ancestor of all the potential types, such as /obj. See "polymorphism".