Each Token with the Token Type "PC" or "NPC" has these properties:
Code: Select all
Dexterity:8
DEX:{floor(Dexterity / 2) - 5}
PB (Proficiency Bonus):2
Weapon0:wpnName=dagger; attackMod={DEX+PB}; critTarget=20; fumbRange=1; effect=;
Code: Select all
[H: input(
"tab1 | Weapons || TAB",
"Weapon0|
wpnName="+getStrProp(Weapon0,"wpnName")+";
attackMod="+getStrProp(Weapon0,"attackMod")+";
critTarget="+getStrProp(Weapon0,"critTarget")+";
FumbRange="+getStrProp(Weapon0,"fumbRange")+";
effect="+getStrProp(Weapon0,"effect")+"
||PROPS|SPAN=TRUE SETVARS=UNSUFFIXED"
)]
Now, the problem:
The effect variable inside the Weapon0 property is supposed to be flexible, to allow outputs like these:
deal (1d8+DEX) piercing damage
Leaving any attack rolls aside, my objective is to get these strings to roll the dice within them, but allow them to be editable easily. I tried changing the parentheses with [brackets], and although this initially works (the damage has a different result each time, which means the rolling works correctly), once you try to open the Input window again, the previous values in the variable are kept (as intended) but replaced by their already evaluated version (as not intended). Using {curly braces} has the same problem, but the output isn't as messy.deal (2d6) piercing damage, or (1d6) if swarm has half HP or lower.
Editing the value for the first time.
Editing the value a second time.
The final display is straightforward:
Code: Select all
[h: wpnName = getStrProp(Weapon0, "wpnName")]
[h: attackMod = getStrProp(Weapon0, "attackMod")]
[h: critTarget = getStrProp(Weapon0, "critTarget")]
[h: fumbRange = getStrProp(Weapon0, "fumbRange")]
[h: effect = getStrProp(Weapon0, "effect")]
[h: attackRoll1 = 1d20]
[h: attackRoll2 = 1d20]
<b>Attack</b>: [wpnName] (+[attackMod])<br>
<b>Effect</b>: [effect]
<!-- Check if attack roll is 1 or 20, do some colorful stuff on either result, output is basically: -->
...
[attackroll1 + attackMod] || [attackroll2 + attackMod]