Skip to Main Content

How to create a new object by a unique class ID at runtime

User_B1Q6EOct 29 2021

What is the proper way to create a new instance of an object by a unique property such as its name or ID, or it’s fully qualified class name. I cannot find a way to do this that is not overtly complicated or required a hard-coded array of every potential object. I’m hoping for something of a similar form to.
newObjecfByID(int ID).constructor(…);

I know RuneScape had a major problem when someone used the wrong item ID and players were receiving an unobtainable item, so there has to be some way to do it. I assume there is a built in way because it would be commonly needed in video games.

thank you for your time!

Post Details
Added on Oct 29 2021