What I would do is use a json object. The key would be the variable name to refer to your data and the value will be your inventory information. This could be just plain text, a string prop or even another json object.
In order to create a key to be a valid variable name, but still be recognizable and converted from the inventory name you will need to filter the item name. For example:
Code: Select all
[H: inventoryName = "Greataxe +1"]
[H: varName = "item." + replace(lower(inventoryName),"[^a-z0-1_.]","") + ".uid" + d1000000000]
What I did is strip out all the characters that don't show up in a variable name and create a unique id so you can have multiple greataxe +1's. The "item." prefix could be there to help you sort and could be there to help identify the category of the item. You would need to save the original name in the data. If you can avoid ";" and quotes in your data using a string prop will work, but to avoid the hassle I would just use another json object for your data. It is assumed that an inventory item will start with a letter, but if not adding the prefix helps prevent naming weirdness.
The next step is putting in your data.
Code: Select all
[H: inventoryText = "A very large axe, made for hurting things, badly."]
[H: item = json.set("{}","flavorText",inventoryText,"name",inventoryName,"damage","1d12")]
[H: inventory = json.set("{}",varName,item)]
You could sort your data.
Code: Select all
[H: sortedInventory = json.sort(inventory,"a","name")]
You could make all the data from an item a local variable.
Code: Select all
[H: item = json.get(inventory,varName)]
[H: item.strprop = json.toStrProp(item)]
[H: varsFromStrProp(item.strprop)]