ID:263393
 
Code:
var/obj/Quest/q = new (startsQuests[k])


startsQuests is an associated list, with the names of quests pointing to the type path for that quest.
For example:
startsQuests = list("Talk to Ezic" = /obj/Quest/ezic)


Problem description:
Now, I want to create an instance of that Quest and give it to the player, which compiles, but it only creates an object of the base Quest type. So when I try to print out quest text or something, I get nothing. If I changed the variable q to the same type path as the quest(var/obj/Quest/ezic/e) it works just fine.

How do I handle creating instances of objects when I don't know exactly what the type path will be?
The format for new is:
Format:
new Type(Args)

I think that in your code, new() is treating the typepath from the list as an argument, rather than as a type. Try throwing the parentheses on the end of the line:
var/obj/Quest/q = new startsQuests[k]()


If that doesn't work (doesn't compile because of the list being there and confusing it), make a temporary variable right above that line, and make it equal to the typepath from the list. Then use that variable instead.
In response to Jon88
Thank you!

The latter of your suggestions worked.