Advertisement Create a free account

[5E OGL] [HELP] setWithWorker on _hasattack attribute not adding the item to Attacks and Spellcasting section

1565463648

Edited 1565464034
I want to use a script that sends the items that are equipped and that has attack to chat with hyperlinks to toggle the equipped and has an attack checkbox. The toggles work fine, and if the items is already in the Attack and Spellcasting section and that I toggle has an attack off, it properly removes the item from the section.  But, when I toggle it back, the checkboxes check themselves, but the item doesn't automatically go back to the Attack and Spellcasting section. FROM CONSOLE -->  ***************************************************************************************************************************************************************** "ReferenceError: update_attacks is not defined\n    at Array.eval (eval at messageHandler (evalmachine.<anonymous>:284:6), <anonymous>:240:13)\n    at self.trigger (evalmachine.<anonymous>:79:37)\n    at messageHandler (evalmachine.<anonymous>:287:11)\n    at process.<anonymous> (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:65:55)\n    at emitTwo (events.js:106:13)\n    at process.emit (events.js:194:7)\n    at process.nextTick (internal/child_process.js:766:12)\n    at _combinedTickCallback (internal/process/next_tick.js:73:7)\n    at process._tickCallback (internal/process/next_tick.js:104:9)" ***************************************************************************************************************************************************************** Any help would be greatly appreciated.  *** I use this for player to swap their weapons and be able to attack with them. If it is not equipped, can't attack with it. Now, if you have 2 hands, you will have to use a bonus action to swap weapons, and if the weapon needs your hands to be used, there shouldn't be more than two weapons in that section.
1565464830
GiGs
Pro
Sheet Author
You said you are using a script. What script are using, and can you post its code?
I use&nbsp;oukag/5eOGLInventoryTracker.js --&gt;&nbsp; <a href="https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92" rel="nofollow">https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92</a> To which I added :&nbsp; To the object ITEM --&gt;&nbsp; &nbsp;HASATTACK_SUFFIX : '_hasattack',&nbsp; HASATTACK : '1', HASNOATTACK : '0', and then mostly duplicated existing functions to add the verification and 'toggling' of the HAS AN ATTACK checkbox within the sheet. It does the checking and unchecking of the boxes fine, but doesnt automatically update the Attacks and Spellcasting section. Only does when I go manually check the box or when untoggling.&nbsp; So, Untoggling the HAS AN ATTACK checkbox through the script while the item is in the Attacks and Spellcasting section does remove the item from the section. But toggling the HAS AN ATTACK checkbox through the script while the item is not in the Attacks and Spellcasting won't succesfully put it back in the section.
I should add that the above Console Message occurs when Untoggling the HAS AN ATTACK checkbox through the script while the item is in the Attacks and Spellcasting. Although it does remove it from Attacks and Spellcasting lol
1565470479

Edited 1565471223
Will also add that I use the companion script. I see&nbsp;update_attacks function all over&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/commit/d349d758f8e98a0051fd6a22070e27c3abb78dd7" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/commit/d349d758f8e98a0051fd6a22070e27c3abb78dd7</a> Companion 5e OGL 1.4.1 ^^ --&gt;&nbsp; <a href="https://gist.github.com/SteveKoontz/7dce834b2285734d8f557f03489531c2" rel="nofollow">https://gist.github.com/SteveKoontz/7dce834b2285734d8f557f03489531c2</a> *** EDIT ** Here? It seems to ignore modifications from the sheetworker &nbsp; &nbsp; on("change:repeating_inventory:hasattack", function(eventinfo) { &nbsp; &nbsp; &nbsp; &nbsp; if(eventinfo.sourceType === "sheetworker") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; var itemid = eventinfo.sourceAttribute.substring(20, 40); &nbsp; &nbsp; &nbsp; &nbsp; getAttrs(["repeating_inventory_" + itemid + "_hasattack", "repeating_inventory_" + itemid + "_itemattackid"], function(v) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var attackid = v["repeating_inventory_" + itemid + "_itemattackid"]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var hasattack = v["repeating_inventory_" + itemid + "_hasattack"]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(attackid &amp;&amp; attackid != "" &amp;&amp; hasattack == 0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remove_attack(attackid); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(hasattack == 1) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; create_attack_from_item(itemid); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; })
1565480354
GiGs
Pro
Sheet Author
Jocelyn C. said: I use&nbsp;oukag/5eOGLInventoryTracker.js --&gt;&nbsp; <a href="https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92" rel="nofollow">https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92</a> To which I added :&nbsp; To the object ITEM --&gt;&nbsp; &nbsp;HASATTACK_SUFFIX : '_hasattack',&nbsp; HASATTACK : '1', HASNOATTACK : '0', and then mostly duplicated existing functions to add the verification and 'toggling' of the HAS AN ATTACK checkbox within the sheet. It does the checking and unchecking of the boxes fine, but doesnt automatically update the Attacks and Spellcasting section. Only does when I go manually check the box or when untoggling.&nbsp; So, Untoggling the HAS AN ATTACK checkbox through the script while the item is in the Attacks and Spellcasting section does remove the item from the section. But toggling the HAS AN ATTACK checkbox through the script while the item is not in the Attacks and Spellcasting won't succesfully put it back in the section. Can you post the version of this script you're using, with your modifications? Maybe in a pastebin or gist rather than here.
I have noticed when inspecting the repeating section in the browser dev tool that the attribute itemattackid 'renews' itself when you manually check the HAS AN ATTACK checkbox. It doesn't when you check the box with the sheeyworker. That, I assume, is why it doesn't go back in the Attack and Spellcasting section
1565482498

Edited 1565483126
Does this work? just created free account and didn't really read but saw it said you need a readme and etc... <a href="https://github.com/Gauzin/ROLL20/blob/0.1/SheetToChat.js" rel="nofollow">https://github.com/Gauzin/ROLL20/blob/0.1/SheetToChat.js</a>
1565484451

Edited 1565489977
And the hasattack value stays 1 when unchecking box with script. I can't even get it to go back to 0, even manually checking or unchecking the box. Even when refreshing the page.&nbsp; Something is bad here :/ good thing I created 2 copies of this game. :D Nevermind this ^^ it actually changes the value. Brain lag involved
1565558572

Edited 1565558604
I want to add that other MODS properties of items are updating the corresponding attributes correctly upon equipping and unequipping from script (AC, Ac+, Stength+, etc...) although I now got additional reference errors from the console --&gt; "ReferenceError: update_weight is not defined" "ReferenceError: update_weight is not defined\n&nbsp; &nbsp; at Array.eval (eval at messageHandler (evalmachine.&lt;anonymous&gt;:284:6), &lt;anonymous&gt;:150:37)\n&nbsp; &nbsp; at self.trigger (evalmachine.&lt;anonymous&gt;:79:37)\n&nbsp; &nbsp; at messageHandler (evalmachine.&lt;anonymous&gt;:287:11)\n&nbsp; &nbsp; at process.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:65:55)\n&nbsp; &nbsp; at emitTwo (events.js:106:13)\n&nbsp; &nbsp; at process.emit (events.js:194:7)\n&nbsp; &nbsp; at process.nextTick (internal/child_process.js:766:12)\n&nbsp; &nbsp; at _combinedTickCallback (internal/process/next_tick.js:73:7)\n&nbsp; &nbsp; at process._tickCallback (internal/process/next_tick.js:104:9)" "ReferenceError: update_initiative is not defined" "ReferenceError: update_initiative is not defined\n&nbsp; &nbsp; at Array.eval (eval at messageHandler (evalmachine.&lt;anonymous&gt;:284:6), &lt;anonymous&gt;:151:38)\n&nbsp; &nbsp; at self.trigger (evalmachine.&lt;anonymous&gt;:79:37)\n&nbsp; &nbsp; at messageHandler (evalmachine.&lt;anonymous&gt;:287:11)\n&nbsp; &nbsp; at process.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:65:55)\n&nbsp; &nbsp; at emitTwo (events.js:106:13)\n&nbsp; &nbsp; at process.emit (events.js:194:7)\n&nbsp; &nbsp; at process.nextTick (internal/child_process.js:766:12)\n&nbsp; &nbsp; at _combinedTickCallback (internal/process/next_tick.js:73:7)\n&nbsp; &nbsp; at process._tickCallback (internal/process/next_tick.js:104:9)" "ReferenceError: update_attacks is not defined" "ReferenceError: update_attacks is not defined\n&nbsp; &nbsp; at Array.eval (eval at messageHandler (evalmachine.&lt;anonymous&gt;:284:6), &lt;anonymous&gt;:158:13)\n&nbsp; &nbsp; at self.trigger (evalmachine.&lt;anonymous&gt;:79:37)\n&nbsp; &nbsp; at messageHandler (evalmachine.&lt;anonymous&gt;:287:11)\n&nbsp; &nbsp; at process.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:65:55)\n&nbsp; &nbsp; at emitTwo (events.js:106:13)\n&nbsp; &nbsp; at process.emit (events.js:194:7)\n&nbsp; &nbsp; at process.nextTick (internal/child_process.js:766:12)\n&nbsp; &nbsp; at _combinedTickCallback (internal/process/next_tick.js:73:7)\n&nbsp; &nbsp; at process._tickCallback (internal/process/next_tick.js:104:9)"
Here is my updated version&nbsp; --&gt;&nbsp; <a href="https://github.com/Gauzin/ROLL20/blob/master/SheetToChat.js" rel="nofollow">https://github.com/Gauzin/ROLL20/blob/master/SheetToChat.js</a> I have added functions to :&nbsp; Show equipped armors. Hyperlink toggles equipped checkbox Show equipped items that have attacks. Hyperlink toggles equipped and hasattack checkboxes Show equipped items that have attacks by Attack Type Melee, Ranged or Thrown. Hyperlink will release the said template (which is my modified powercards script for now) --&gt; IN PROGRESS
1565628087
keithcurtis
Forum Champion
API Scripter
If you think this issue might have anything to do with this thread , please post a report there as well? There's been a long standing issue with the API and Sheet Workers, and more data couldn't hurt.
Yep. Pretty much seems like it. At least, very similar to yours. Good job on tracking my post for it to get even more traction. How would you proceed in that case? Would you simply repost there what I posted here?
1565650042

Edited 1565650067
keithcurtis
Forum Champion
API Scripter
There are a couple of sample cases already posted in the thread. For making it simpler for the developers, maybe try to follow that format along with your findings? There's no real precedent for it, so "do as thou wilt".
1565654772

Edited 1565654811
Allright!&nbsp; Will do shortly. Thx Keith! Let's hope it resolves soon. I know you've been dealing with it longer than I did&nbsp; &nbsp;have&nbsp;&nbsp;:P
1565757223
GiGs
Pro
Sheet Author
I wish i had more time to look at this, but its a pretty complex problem involving multiple scripts and a sheet I'm not familiar with. Have you tried restoring the original versions of any scripts you've edited, for testing purposes? I'd recommend doing that, and seeing if you still get errors.&nbsp; Either way, it is probably worth asking the creators of those scripts for advice. Your posts to github did work, btw.&nbsp;