Excellent Tool Pyro. I created a cleanup macro. If you have a item type and change your mind later and want to get rid of that type, it leaves residual data in the Items area. For instance, while messing around with the your tool and trying to figure out how I wanted to organize the items I started with a type "weapon". Later I decided to break it into 2 types "melee weapon" and "range weapon". Even though the editor seemingly allowed me to delete that type, it only removed it from "ItemTypes" not the "Items" area. This macro goes through all the "Items" and if they are not in the Item types it removes them. It could be easily rewritten to use your functions, but when I wrote it I was still unfamiliar with them. It spits out the names of any cleaned Items as it's going.
Cleaner:
Code: Select all
[h: InventoryType = macro.args]
[h: Subtypes = json.get(eval(InventoryType), "ItemTypes")]
[h: Items = json.get(eval(InventoryType), "Items")]
[h: Fields = json.fields(Items,"json")]
[h: json.fields(Items,"json")]
[foreach(curItem, Fields, ""), code:
{
[if(json.contains(Subtypes,curItem) == 0), code:
{
[curItem]
[h: Items = json.remove(Items,curItem)]
};{}]
}]
[setProperty(InventoryType,json.set(eval(InventoryType), "Items", Items))]
I also added a couple macros to also allow it to be a general json editor as well (basically another cleaner that strips out the "EquipSlots","EquipSlotTypes" and "Equipped") your dialog editor still works without these and it I like this gui better than your other json editor. At the moment I plan on your Lib as a Master DataBase that the player tokens reference to get their equipment data. So a player token might only reference a name and id# for a weapon on their actual token, and its data is all kept securely on the lib token. Then if i make a change or whatever it automatically is propagated to all of the players without them doing anything. At least that's my plan at the moment. We'll see if it works out.
Cleaner & Make Generic:
Code: Select all
[h: InventoryType = macro.args]
[h: Subtypes = json.get(eval(InventoryType), "ItemTypes")]
[h: Items = json.get(eval(InventoryType), "Items")]
[h: Fields = json.fields(Items,"json")]
[h: json.fields(Items,"json")]
[h: setProperty(InventoryType,json.remove(eval(InventoryType),"EquipSlots"))]
[h: setProperty(InventoryType,json.remove(eval(InventoryType),"EquipSlotTypes"))]
[h: setProperty(InventoryType,json.remove(eval(InventoryType),"Equiped"))]
[foreach(curItem, Fields, ""), code:
{
[if(json.contains(Subtypes,curItem) == 0), code:
{
[curItem]
[h: Items = json.remove(Items,curItem)]
};{}]
}]
[h: setProperty(InventoryType,json.set(eval(InventoryType), "Items", Items))]