Variables Question

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
qcgreywolf
Cave Troll
Posts: 43
Joined: Mon Dec 09, 2013 10:23 pm

Variables Question

Post by qcgreywolf »

Ok, I am stumped. I can't get a silly little snippet of code to work. I've got my skill modifiers in a key-pair string prop (Acrobatics=3,Arcana=2,Athletics=0.....). I call an input() to choose which skill I want to roll, then pull the modifier from the skill add it to the roll and that's it.

The only oddity is, I decided I wanted the players to be able to "Name" up to 2 Lore skills (PF 2e), so I have a Lore1a, Lore1b, Lore2a, Lore2b set, "A"'s are the names and "B"'s are the modifier. No matter what I do, I can't get the macro to pull the modifier from ONLY the lore keypairs. Everything else works, and I can pull the Names of the Lore pairs just fine. If I ask the macro to roll an Acrobatics check or a Medicine check, it works just fine.

In the code snippet, I even tried using number() on the Lore1 code and just variable = variable on the Lore2 code. Both instances result in a completely blank skill modifier. By putting random [r:] junk text into the if() branches, I know the if() branches are working properly. And if I put a [Lore1b] randomly in the beginning of the macro, I can see that it is pulling a number from the MainSkill property.

What am I missing?

Code: Select all

[h: gmOnly = isNPC()]

[h: varsFromStrProp(MainSkills)]

[h: Lore1 = Lore1a)]
[h: Lore2 = Lore2a)]

[h: status = input(
	strformat("skillToRoll|Acrobatics, Arcana, Athletics, Crafting, Deception, Diplomacy, Intimidation, %{Lore1a}, %{Lore2a}, Medicine, Nature, Occultism, Perception, Performance, Religion, Society, Stealth, Survival, Thievery|Skill to Roll|RADIO|SELECT=12 VALUE=STRING"),
	strformat("gmOnly|%{gmOnly}|Secret Roll|CHECK")
)]

[h:abort(status)]

[ if(skillToRoll == Lore1), CODE:
{
	[h: skillModifier = number(Lore1b)]
};{}]

[ if(skillToRoll == Lore2), CODE:
{
	[h: skillModifier = Lore2b]
	
};{

	[h: skillModifier = getStrProp(MainSkills, skillToRoll)]		
}]

[h: Random.Roller(20)]
[h: dieRoll = number(outputRoll)]
[h: skillRoll = dieRoll + skillModifier + TempSkillModifier]
[h: totalModifier = skillModifier + TempSkillModifier]


  [h: output.tip = strformat("<html>
   <table><tr><td colspan=2><b><center>%{skillToRoll} Check</center></b></td></tr>
      <tr><td>Skill Modifier:</td><td>%{skillModifier}</td><td>Temporary Modifiers:</td><td>%{TempSkillModifier}</td></tr>
      <tr><td>D20 Roll:</td><td>%{dieRoll}</td><td>Final Modifier: %{totalModifier}</td></tr>
   </table></html>")]

[h: outputText = strformat("<b>%{skillToRoll}</b> check = %{skillRoll}.")]

[r: nad.lib.Text()]

qcgreywolf
Cave Troll
Posts: 43
Joined: Mon Dec 09, 2013 10:23 pm

Re: Variables Question

Post by qcgreywolf »

I got a very helpful reply from Aliasmask in the Discord channel. Thanks!

Solution:

Code: Select all

[h: gmOnly = isNPC()]

[h: varsFromStrProp(MainSkills)]

[h: Lore1 = Lore1a)]
[h: Lore2 = Lore2a)]

[h: status = input(
	strformat("skillToRoll|Acrobatics, Arcana, Athletics, Crafting, Deception, Diplomacy, Intimidation, %{Lore1a}, %{Lore2a}, Medicine, Nature, Occultism, Perception, Performance, Religion, Society, Stealth, Survival, Thievery|Skill to Roll|RADIO|SELECT=12 VALUE=STRING"),
	strformat("gmOnly|%{gmOnly}|Secret Roll|CHECK")
)]

[h:abort(status)]

[H: skillModifier = ""]
[H, if(skillToRoll == Lore1): skillModifier = getStrProp(MainSkills,"Lore1b")]
[H, if(skillToRoll == Lore2): skillModifier = getStrProp(MainSkills,"Lore2b")]
[H, if(json.isEmpty(skillModifier)): skillModifier = getStrProp(MainSkills,skillToRoll)]

[h: Random.Roller(20)]
[h: dieRoll = number(outputRoll)]
[h: skillRoll = dieRoll + skillModifier + TempSkillModifier]
[h: totalModifier = skillModifier + TempSkillModifier]


  [h: output.tip = strformat("<html>
   <table><tr><td colspan=2><b><center>%{skillToRoll} Check</center></b></td></tr>
      <tr><td>Skill Modifier:</td><td>%{skillModifier}</td><td>Temporary Modifiers:</td><td>%{TempSkillModifier}</td></tr>
      <tr><td>D20 Roll:</td><td>%{dieRoll}</td><td>Final Modifier: %{totalModifier}</td></tr>
   </table></html>")]

[h: outputText = strformat("<b>%{skillToRoll}</b> check = %{skillRoll}.")]

[r: nad.lib.Text()]

Post Reply

Return to “Macros”