Another JSON Question

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
User avatar
Dervish
Giant
Posts: 121
Joined: Thu Sep 15, 2011 7:52 pm

Another JSON Question

Post by Dervish »

okay i am tinkering with my 5E frame work trying to incorporate expertise into the skill macro here is the macro i currently have

Code: Select all

[h:skillName = macro.args]
[b][h:proficient = json.get(skillName,"Proficient")]
[h:expert = json.get(skillName,"Expert")]
[h:proficiency = getProperty("Proficiency")][/b]

[h:Str = getProperty("Strength")]
[h:Dex = getProperty("Dexterity")]
[h:Con = getProperty("Constitution")]
[h:Int = getProperty("Intelligence")]
[h:Wis = getProperty("Wisdom")]
[h:Cha = getProperty("Charisma")]

[h, switch(skillName):
case "Acrobatics": statName = Dex;
case "Arcana": statName = Int;
case "Athletics": statName = Str;
case "Deception": statName = Cha;
case "History": statName = Int;
case "Husbandry": statName = Wis;
case "Insight": statName = Wis;
case "Intimidation": statName = Cha;
case "Investigation": statName = Int;
case "Medicine": statName = Wis;
case "Nature": statName = Int;
case "Perception": statName = Wis;
case "Performance": statName = Cha;
case "Persuasion": statName = Cha;
case "Prestidigitation": statName = Dex;
case "Religion": statName = Int;
case "Stealth": statName = Dex;
case "Survival": statName = Wis;
case "Strength_Save":StatName= Str;
case "Constitution_Save":StatName= Con;
case "Dexterity_Save":StatName= Dex;
case "Intelligence_Save":StatName= Int;
case "Wisdom_Save":StatName= Wis;
case "CharismaSave":StatName= Cha;
]


[h,if(proficient == 1): SkillMod1 = proficiency; SkillMod1 = 0]
[h,if(expert == 1): SkillMod2 = proficiency; SkillMod2 = 0]
[h:SkillMod = SkillMod1 + SkillMod2]

[h:skill = eval(skillName)]

[H: hasFumble = 0]
[H: hasCrit = 0]
[H: bothCrit = 0]
[H: isFumble = 0]
[H: isCrit = 0]
[H: output = ""]
[H, code: {
   [H: roll1 = d20]
   [H: roll2 = d20]
   [H, if(roll1 == 20 || roll2 == 20): hasCrit = 1]
   [H, if(roll1 == 20 && roll2 == 20): bothCrit = 1]
   [H, if(roll1 == 1 || roll2 == 1): hasFumble = 1]
   [H, if(roll1 == 20): isCrit = 1]
   [H, if(roll1 == 1): isFumble = 1]
   [H: baseCheck = roll1 + statMod + SkillMod + misc]
   [H, if(roll2 < roll1), code: {
      [H: disadCheck = roll2 + statMod + SkillMod + misc]
      [H: advCheck = baseCheck]
   };{
      [H: disadCheck = baseCheck]
      [H: advCheck = roll2 + statMod + SkillMod + misc]
   }]
   
   [H:
      tip = strformat('<html><table style="border-style:solid;border-width=1pt;padding:0px;">     
         <tr style="padding:0px;"><td style="padding:0px;padding-right:5px;text-align:right;">Roll 1:</td><td style="padding:0px;padding-right:5px;">%{roll1}</td></tr>
         <tr style="padding:0px"><td style="padding:0px;padding-right:5px;text-align:right;">Roll 2:</td><td style="padding:0px;padding-right:5px;">%{roll2}</td></tr>

<tr style="padding:0px"><td style="padding:0px;padding-right:5px;text-align:right;">Skill Proficiency:</td><td style="padding:0px;padding-right:5px;">%{SkillMod}</td></tr>
 <tr style="padding:0px"><td style="padding:0px;padding-right:5px;text-align:right;">Stat Mod:</td><td style="padding:0px;padding-right:5px;">%{statMod}</td></tr>
 <tr style="padding:0px"><td style="padding:0px;padding-right:5px;text-align:right;">Misc:</td><td style="padding:0px;padding-right:5px;">%{misc}</td></tr>



         </table></html>'
   )]
   [H: tip = replace(tip,'"',""")]
   [H, if(hasFumble): disadCheck = "<font color=red size=+1>"+disadCheck+"</font>"]
   [H, if(hasCrit): advCheck = "<font color=green size=+1>"+advCheck+"</font>"]
   [H, if(bothCrit): disadCheck = "<font color=green size=+1>"+disadCheck+"</font>"]
   [H, if(isFumble): baseCheck = "<font color=red size=+1>"+baseCheck+"</font>"]
   [H, if(isCrit): baseCheck = "<font color=green size=+1>"+baseCheck+"</font>"]
   [H:
      output = json.append(output,strformat('
         <span title="%{tip}"><b>
            %{skillName}'
   ))]
 
   [H:
      output = json.append(output,strformat('
            Result:%{baseCheck}  (Adv: %{advCheck} / Dis: %{disadCheck})<br></b>
         </span>'
   ))]
}]
[R: json.toList(output,"<br>")]

the result i get is this

Code: Select all

  Statement options (if any): h       Statement Body : proficient = json.get(skillName,"Proficient")


i know its likely something i am overlooking and i know i am going to feel very dumb


my skill properties are set up like this

Acrobatics:{"Proficient":0,"Expert":0} so each skill is its own object eventually i want to condense the entire skill list down into a singular object but one step at a time
Last edited by Dervish on Tue May 12, 2015 7:57 pm, edited 1 time in total.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Another JSON Question

Post by aliasmask »

Verify skillName is a json object.

User avatar
Dervish
Giant
Posts: 121
Joined: Thu Sep 15, 2011 7:52 pm

Re: Another JSON Question

Post by Dervish »

this is how i call my macros

Code: Select all

<a href="macro://_skillCheck@Lib:Character/all/selected?Acrobatics">


skillName is the argument each skill is an object I am assuming i am calling the wrong thing i will work on it more try to shake something loose

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Another JSON Question

Post by aliasmask »

"Acrobatics" is what macro.args equals which is not a json object. Where is "Proficient" stored because it's not in skillName.

User avatar
Dervish
Giant
Posts: 121
Joined: Thu Sep 15, 2011 7:52 pm

Re: Another JSON Question

Post by Dervish »

Thanks man just had the Aha! moment and as predicted i feel really stupid I had to add [h:skill = skillName] in order to write to individual skills

Post Reply

Return to “MapTool”