I am getting an error when I plug in what you have to what I have, so...
here is my weapon skills macro that does work:
Code: Select all
[h: abort(input(
"tab0 | Combat || TAB",
"junk|<html><img src='"+replace(getTokenImage(), ":", ":")+"' height=120 width=120></img></html>|-|LABEL|SPAN=TRUE",
"junkVar|Skill Value|Skill|LABEL",
"Armor|" +json.get(SkillsWeapons,"Armor")+ "|Armor",
"Shield|" +json.get(SkillsWeapons,"Shield")+ "|Shield",
"junkVar|-----|-----|LABEL",
"junkVar|Skill Value|Skill|LABEL",
"Blunt|" +json.get(SkillsWeapons,"Blunt")+ "|Blunt",
"Flail|" +json.get(SkillsWeapons,"Flail")+ "|Flail",
"Hand_to_hand|" +json.get(SkillsWeapons,"Hand_to_hand")+ "|Hand to hand",
"Martial|" +json.get(SkillsWeapons,"Martial")+ "|Martial",
"Missile|" +json.get(SkillsWeapons,"Missile")+ "|Missile",
"Piercing|" +json.get(SkillsWeapons,"Piercing")+ "|Piercing",
"Slashing|" +json.get(SkillsWeapons,"Slashing")+ "|Slashing",
"Throwing|" +json.get(SkillsWeapons,"Throwing")+ "|Throwing"
))]
[h: jsonCombat = json.set("{}", "Armor", Armor, "Shield", Shield, "Blunt", Blunt, "Flail", Flail, "Hand_to_hand", Hand_to_hand, "Martial", Martial, "Missile", Missile, "Piercing", Piercing, "Slashing", Slashing, "Throwing", Throwing)]
[h: setProperty("SkillsWeapons", jsonCombat)]
Weapon skills set.
The code I am trying to work for is my equipping weapons macro. I tried to adjust it, but I don't know what I am missing (again).
My Campaign Property(ies) is()are:
EquipmentWeapons {"W1Name":0, "W1Class":0, "W1Damage":0, "W1Fail":1, "W1Crit":10, "W2Name":0, "W2Class":0, "W2Damage":0, "W2Fail":1, "W2Crit":10, "W3Name":0, "W3Class":0, "W3Damage":0, "W3Fail":1, "W3Crit":10}
SkillsWeapons {"Armor":0,"Shield":0,"Blunt":0,"Flail":0,"Hand_to_hand":0,"Martial":0,"Missile":0,"Piercing":0,"Slashing":0,"Throwing":0}
The error I am getting is:
Error in body of roll.
Statement options (if any): H
Statement Body : weapons = json.get("EquipmentWeapons")
Code: Select all
<!-- Definitions -->
[H: weaponClasses = "none,Blunt,Handtohand,Flail,Martial,Missile,Piercing,Slashing,Thrown,"]
[defaultWeapons = json.set("{}", "W1Name", "Weapon1", "W1Class", "none", "W1Damage", 0, "W1Fail", 1, "W1Crit", 10, "W2Name", "Weapon2", "W2Class", "none", "W2Damage", 0, "W2Fail", 1, "W2Crit", 10, "W3Name", "Weapon3", "W3Class", "none", "W3Damage", 0, "W3Fail", 1, "W3Crit", 10)]
<!-- get token weapon list, otherwise use default values. Merge existing with default value in case values are undefined or missing -->
[H: weapons = json.get("EquipmentWeapons")]
[H, if(json.isEmpty(weapons)): weapons = defaultWeapons; weapons = json.merge(defaultWeapons,weapons)]
<!-- trick: define all values in weapons as local variables -->
[H: varNames = json.fields(weapons)]
[H: weaponProps = json.toStrProp(weapons)]
[H: varsFromStrProp(weaponProps)]
<!-- find select values in weapons list for default values -->
[H: w1Select = max(0,listFind(weaponClasses, W1Class))]
[H: w1Select = max(0,listFind(weaponClasses, W2Class))]
[H: w1Select = max(0,listFind(weaponClasses, W3Class))]
<!-- update weapon info -->
[h: abort(input(
strformat("weapon1.input|Weapon 1|Weapon 1|LABEL"),
strformat("W1Name|%{W1Name}|Weapon 1|TEXT"),
strformat("W1Class|%{weaponClasses}|Choose Skill|LIST|SELECT=%{w1Select} VALUE=STRING"),
strformat("W1Damage|%{W1Damage}|Damage|TEXT"),
strformat("W1Fail|%{W1Fail}|Fail|TEXT"),
strformat("W1Crit|%{W1Crit}|Critical|TEXT"),
strformat("weapon2.input|Weapon 2|Weapon 2|LABEL"),
strformat("W2Name|%{W2Name}|Weapon 2|TEXT"),
strformat("W2Class|%{weaponClasses}|Choose Skill|LIST|SELECT=%{w2Select} VALUE=STRING"),
strformat("W2Damage|%{W2Damage}|Damage|TEXT"),
strformat("W2Fail|%{W2Fail}|Fail|TEXT"),
strformat("W2Crit|%{W2Crit}|Critical|TEXT"),
strformat("weapon3.input|Weapon 3|Weapon 3|LABEL"),
strformat("W3Name|%{W3Name}|Weapon 3|TEXT"),
strformat("W3Class|%{weaponClasses}|Choose Skill|LIST|SELECT=%{w3Select} VALUE=STRING"),
strformat("W3Damage|%{W3Damage}|Damage|TEXT"),
strformat("W3Fail|%{W3Fail}|Fail|TEXT"),
strformat("W3Crit|%{W3Crit}|Critical|TEXT")
))]
<!-- Save Changes -->
[H: weaponProps = strPropFromVars(varNames,"UNSUFFIXED")]
[H: setProperty("skillsWeapons",json.fromStrProp(weaponProps))]
[R: "Weapons configured and saved."]