Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Watcher TextToChat not grabbing all fields... wtf?

1652678343

Edited 1652680759
Hey Guys! Okay... the hole in the wall keeps getting bigger from my head... I have a set of fields which when defined I want to be displayed in the chat.&nbsp; Pretty standard. Hit Roll, Dmg Roll, Weapons Range, notes, etc.&nbsp; But the Watcher doesn't seem to be grabbing all the lines. Just 4: Weapon Name, Dmg Roll, Penetration, Ammunition This is what it currently looks like when rolled: But it should have 6 more rows of data! And they are not sequential, meaning the data should be peppered between some of the above image. Here is the HTML that defines the weapons stats: (I Know, I have to update it to the new "non table" method...) //Combat section where you define the weapons stats// &lt;div class="widget borderedContainer"&gt; &lt;span class="subheading"&gt;Ranged Weapon&lt;/span&gt;&lt;br /&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Weapon&lt;/td&gt; &lt;td colspan="3"&gt;&lt;input class="inputfield text gold-color" style="width: 200px;" type="text" name="attr_rangedWeapon" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Damage&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="text" name="attr_rangedDamage" /&gt;&lt;/td&gt; &lt;td&gt;RoF&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="text" name="attr_rangedRoF" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Rpd Fire&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="text" name="attr_rangedDamage_rf"/&gt;&lt;/td&gt; &lt;td&gt;RF DR&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="text" name="attr_rangedDamage_rf_dr"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Range&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="number" name="attr_rangedRange" min="0" max="9999"/&gt;&lt;/td&gt; &lt;td&gt;Hit bonus&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="number" name="attr_rangedHitBonus" min="0" max="9999"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;P+&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="number" name="attr_rangedPenetrationPlus" min="0" max="9999"/&gt;&lt;/td&gt; &lt;td&gt;Notes&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="text" name="attr_ranged_notes" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Ammunition&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="number" name="attr_rangedAmmunition" min="0" max="9999"/&gt;&lt;/td&gt; &lt;td&gt;/&lt;/td&gt; &lt;td&gt;&lt;input class="inputfield text blue-color" style="width: 80px;" type="number" name="attr_rangedAmmunition_max" min="0" max="9999"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;/tr&gt; &lt;/table&gt;&lt;br /&gt; &lt;table&gt; &lt;tr&gt; &lt;td style="width:50px"&gt;&lt;button class="blank-roll-button" type="roll" value="@{rangedRoll}" &gt;Attack&lt;/button&gt;&lt;/td&gt; &lt;td style="width:50px"&gt;&lt;button type="action" class="blank-roll-button" name="act_rangedAmmoReduce" &gt;Ammo-&lt;/button&gt;&lt;/td&gt; &lt;td style="width:50px"&gt;&lt;button type="action" class="blank-roll-button" name="act_rangedAmmoReload" &gt;Reload&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; Here is the watcher for this section: // Watching for when rangedweapon change on('change:rangedWeapon change:rangedDamage change:rangedRoF change:rangedDamage_rf change:ranged_rf_dr change:rangedPenetrationPlus change:rangedHitBonus change:rangedRange change:ranged_notes change:rangedAmmunition change:rangedAmmunition_max', function(eventInfo) { getAttrs([ 'rangedWeapon' 'rangedDamage' 'rangedRoF' 'rangedDamage_rf' 'ranged_rf_dr' 'rangedPenetrationPlus' 'rangedHitBonus' 'rangedRange' 'ranged_notes' 'rangedAmmunition' 'rangedAmmunition_max',], function(values) { let textToChat = "&amp;{template:default}"; // let rf_dmg = rangedDamage * rangedDamaged_rf; textToChat = textToChat.concat(" {{Name= " + values.rangedWeapon + "}}"); textToChat = textToChat.concat(" {{Dmg= [[" + values.rangedDamage + "]]}}"); textToChat = textToChat.concat(" {{RoF= " + values.rangedRoF + "}}"); textToChat = textToChat.concat(" {{RF DR=" + values.ranged_rf_dr + "}}"); textToChat = textToChat.concat(" {{RF Damage= [[" + values_rangedDamage * values.rangedDamage_rf + "]]}}"); textToChat = textToChat.concat(" {{Penetration= " + values.rangedPenetrationPlus + "}}"); textToChat = textToChat.concat(" {{Hit= [[1d20+" + values.rangedHitBonus + "]]}}"); textToChat = textToChat.concat(" {{Range= " + values.rangedRange + "}}"); textToChat = textToChat.concat(" {{Notes= " + values.ranged_notes + "}}"); textToChat = textToChat.concat(" {{Ammunition= " + String(parseInt(values.rangedAmmunition)-1) + " / " + values.rangedAmmunition_max + "}}"); console.log(textToChat); setAttrs({ rangedRoll : textToChat }); }); }); Here is a link to the full sheet if you think the issue is elsewhere. <a href="https://github.com/MavSantroy/Drakudai/blob/main/Drakudai%20Hero%20Sheet%205-11-2022" rel="nofollow">https://github.com/MavSantroy/Drakudai/blob/main/Drakudai%20Hero%20Sheet%205-11-2022</a>&nbsp;
UPDATE! Okay, I have NOOOO idea wtf... But check it out. If I change the name of the weapon, or any of the stats, they don't change! But, I can go into the Attributes and Abilities Tab and find the rangedRoll attribute and the data field is the unchanged data! It's not updating the attribute for rangedRoll!
UPDATE! Pretty sure the entire page is not being updated properly... FML
Okay, yeah, so rangedRoll (the attr/call/whatever) isn't being updated when you change out the stats. I'm lost..
1652818092

Edited 1653087181
John D.
Pro
Sheet Author
Michael, Two issues pop out at me immediately.&nbsp; First, in your getAttrs() call, the first variable should be an array.&nbsp; Therefore, each element needs to be comma separated, but you only have a single comma at the end of the list. Secondly, looking at your full sheet on GitHub, there is no attribute named "rangedRoll" that you're trying to write to.&nbsp; This should be a hidden input by the looks of how you're trying to use dynamic roll button values.&nbsp; Example: &lt;input type="hidden" name="attr_rangedRoll" value="&amp;{template:default}..." /&gt; Probably a good idea just to nest some generic value in case a player clicks the button without modifying any of the values you're capturing. Also, for joining strings you could simply do this: let textToChat = "&amp;{template:default}"; textToChat += " {{stuff}}"; textToChat += " {{most stuff}}"; And I would also recommend getting familiar with template literals instead of straight up string mangling, like so... let textToChat = "&amp;{template:default}"; textToChat += ` {{Name= ${values.rangedWeapon}}}`; textToChat += ` {{Dmg= [[${values.rangedDamage}]]}}`; If you're not doing so already, I recommend using a more advanced code editor.&nbsp; It will change your life.&nbsp; I like to use Visual Studio Code.&nbsp; There are tons of plug-ins for coloring, formatting, and sanity checking your code.&nbsp; The array issue above was discovered the moment I dropped your javascript into it.&nbsp; And it's free!
Thank you so much!!!&nbsp; I'll look into this and report back!