Hi all, I have just tried to use the following script to randomise my NPC's HP but it doesn't seem to implement the token-mod set bar1 part. If I input the token mod code into chat myself it works but it doesn't through the macro script. This is the code I am using <a href="https://app.roll20.net/forum/post/10000297/scritpcard-api-working-and-sharing/?pageforid=10419857#post-10419857" rel="nofollow">https://app.roll20.net/forum/post/10000297/scritpcard-api-working-and-sharing/?pageforid=10419857#post-10419857</a> !script {{
--/|Script Name : Set Monster HP
--/|Version : 1.0
--/|Requires SC : 1.4.0+
--/|Author : Will M.
--/|Description : Utility function that resets all selected NPC hps based on the HPFormula (with a twist)
--/| Twist - It allows for the following HP calcs:
--/| Default - Standard static HP based on HPFormula (no randomness)
--/| Random - Uses the HPFormula to derive HP
--/| Random High (x Rolls) - Will take the highest value of x(2,5, or 10) rolls.
--/| Random Low (x Rolls) - Will take the lowest value of x(2,5, or 10) rolls.
--/|
--/| Adder - A value (+/-) to add to the final result
--#title|Set Monster HP
--#reentrant|SetMonsterHP
--#titleCardBackground|#932729
--#whisper|self
--#oddRowBackground|#FFFFFF
--#evenRowBackground|#FFFFFF
--#buttonbackground|#FFFFFF
--#buttontextcolor|#0905f2
--#buttonbordercolor|#FFFFFF
--#bodyFontSize|11px
--#debug|1
--/| set to bar2_value or bar3_value if you use one of those two for tracking HP
--&HPField|bar1_value
--/| Modes 0-Default,1-Random,2-Random (High), 3 Random (Low)
--&Mode|0
--&Adder|0
--&HP_ROLL_COUNT|0
--&Mode|?{HP Set Mode?|Default,0|Random,1|Random High(2 Rolls),2.2|Random High(5 Rolls),2.5|Random High(10 Rolls),2.10|Random Low(2 Rolls),3.2|Random Low(5 Rolls),3.5|Random Low(10 Rolls),3.10}
--&Adder|?{Additional Adder|0}
--+Adder|[&Adder]
--?[&Mode] -eq 2.2|[ --&Mode|2 --&HP_ROLL_COUNT|2 --]|
--?[&Mode] -eq 2.5|[ --&Mode|2 --&HP_ROLL_COUNT|5 --]|
--?[&Mode] -eq 2.10| [ --&Mode|2 --&HP_ROLL_COUNT|10 --]|
--?[&Mode] -eq 3.2|[ --&Mode|3 --&HP_ROLL_COUNT|2 --]|
--?[&Mode] -eq 3.5|[ --&Mode|3 --&HP_ROLL_COUNT|5 --]|
--?[&Mode] -eq 3.10|[ --&Mode|3 --&HP_ROLL_COUNT|10 --]|
--=i|0
--/| !token-mod --set bar1|[[@{selected|npc_hpformula}]]
--/| For each selected Token
--~Token|getselected
--+TokenCount|[&TokenCount]
--+Mode|[&Mode]
--:MAIN_LOOP_TOP|
--?[$i.Raw] -eq [&TokenCount]|MAIN_LOOP_EXIT
--=i|[$i] + 1
--/| If it is an NPC token associated with a monster sheet then proceed
--?[*[&Token[$i.Raw]]:npc] -ne 1|MAIN_LOOP_TOP
--?"[*[&Token[$i.Raw]]:t-represents]" -ninc "-"|MAIN_LOOP_TOP
--/| Get the npc_hpformula
--&CharId|[*[&Token[$i.Raw]]:t-represents]
--&HPFormula|[*[&CharId]:npc_hpformula]
--/| Based on Mode - determine HP
--C[&Mode]|0:MODE_DEFAULT|1:MODE_RANDOM|2:MODE_RAND_HIGH|3:MODE_RAND_LOW
--/|Case 0 - Default
--:MODE_DEFAULT|
--=HP|[*[&CharId]:hp^] + [&Adder]
--^END_CASE|
--/|Case 1 - Random
--:MODE_RANDOM|
--=HP|[&HPFormula] + [&Adder]
--^END_CASE|
--/|Case 2 - Random - High
--:MODE_RAND_HIGH|
-->HP_RAND_HIGH|
--^END_CASE|
--/|Case 3 - Random - Low
--:MODE_RAND_LOW|
-->HP_RAND_LOW|
--^END_CASE|
--:END_CASE|
--+[$i.Raw].|[*[&Token[$i.Raw]]:t-name]: ([&HPFormula]) + [&Adder] [$HP]
--@token-mod|_set [&HPField]|[$HP.Raw] _ids [&Token[$i.Raw]] _ignore-selected
--/|Apply Calculated HP
--/| Next token
--^MAIN_LOOP_TOP|
--:MAIN_LOOP_EXIT|
--+Done!|
--X|
--:HP_RAND_HIGH|
--=HP|-500
--=j|0
--:HPRH_LOOP_TOP|
--?[$j.Raw] -eq [&HP_ROLL_COUNT]|HPRH_LOOP_END
--=x|[&HPFormula] + [&Adder]
--+&nbsp;&nbsp;RHigh(x / HP)|[$x] / [$HP]
--~HP|math;max;[$HP];[$x]
--=j|[$j] + 1
--^HPRH_LOOP_TOP|
--:HPRH_LOOP_END|
--<|
--:HP_RAND_LOW|
--=HP|500
--=j|0
--:HPRL_LOOP_TOP|
--?[$j.Raw] -eq [&HP_ROLL_COUNT]|HPRL_LOOP_END
--=x|[&HPFormula] + [&Adder]
--+&nbsp;&nbsp;RLow(x / HP)|[$x] / [$HP]
--~HP|math;min;[$HP];[$x]
--=j|[$j] + 1
--^HPRL_LOOP_TOP|
--:HPRL_LOOP_END|
--<|
}}