Forum Stats

  • 3,853,687 Users
  • 2,264,255 Discussions


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

User_B1Q6E Member Posts: 1 Green Ribbon

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!