ID:2052669
 
(See the best response by Kaiochao.)
Code:
for(var/id in inventory)
var/list/inventory_row = Load_Inventory_Row(id)
var/list/item_row = Load_Item_Row(inventory_row["item_id"])
var/h = item_row["object_path"]
// item_row[object)path] = /item/Potion/Tiny_Health_Pot

var/obj/i =new (h) //This does not work
// var/obj/i = new ("[h]") // This does not work


/* This does work
var/obj/i = new (/item/Potion/Tiny_Health_Pot)
*/


Problem description:

So basically I have a database table that holds the players inventory which references another table of Items which the player can customize. What I want to do is loop through and create each item and add it to the players inventory. However I am having some trouble creating the objects dynamically. I think its probably just bad syntax on my part but I am not sure the correct way to do this.
So I got it working you can see the answer in the code below.

for(var/id in inventory)
var/list/inventory_row = Load_Inventory_Row(id)
var/list/item_row = Load_Item_Row(inventory_row["item_id"])
var/h = item_row["object_path"]
var/obj/j = new h //cant believe this worked lol
Best response
var/obj/i = new (h)

This creates a new /obj instance with the first argument to obj.New() being h. Of course it wouldn't use h as the type.

var/obj/j = new h

This uses h as the type and specifies no arguments to the New() of h. The trick here is that h is text, which is secretly supported by the 'new' instruction.

It might also help to know that ispath() and text2path() exists.