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

[Script] ChatSetAttr - set character attributes via chat messages

Is it happy dance time? Riley rolled out that change you needed. 
1484684399
Jakob
Sheet Author
API Scripter
I just pushed 1.2 The script now uses the new setWithWorker functionality by default. A toggle in the options exists to return to the old attr.set() behaviour. A word of caution: some initial testing seems to show that setWithWorker does not work very reliably yet. But at least the functionality is there now...
When you say reliable are you speaking of time to do or it just never gets done? I have noticed the API seem very, very slow to load today in general. 
1484693387

Edited 1484693398
Jakob
Sheet Author
API Scripter
Gary W. said: When you say reliable are you speaking of time to do or it just never gets done? I have noticed the API seem very, very slow to load today in general.  I've had some cases where it didn't work at all, but haven't tried a serious reproduction so far. The long loading time is because it builds an index of all your campaign objects when the API starts up now. This can take quite a while if the campaign has a lot of characters. On the plus side, it makes certain API functions significantly faster.
1484747969
Jakob
Sheet Author
API Scripter
I added the fix for repeating sections into 1.2. repeating_blabla_$5_snizzle should now always refer to the attribute snizzle as seen in the 6th row of the repeating_blabla section on the character sheet.
1484802986

Edited 1484803082
vÍnce
Pro
Sheet Author
I was all excited with the new update to the API... On the Pathfinder sheet, I just tried !setattr --sel --repeating_buff_-kap1fyvzj0xx7fhbq0k_buff-enable_toggle|1 which toggles the buff, but this is still not recognized by the sheet sheet worker. Thoughts?
1484803059

Edited 1484803140
The Aaron
Pro
API Scripter
Likely this:&nbsp; <a href="https://app.roll20.net/forum/permalink/4514812/" rel="nofollow">https://app.roll20.net/forum/permalink/4514812/</a> and this:&nbsp; <a href="https://app.roll20.net/forum/permalink/4513979/" rel="nofollow">https://app.roll20.net/forum/permalink/4513979/</a>
1484803089
The Aaron
Pro
API Scripter
Summary: &nbsp;Sheet worker checks that the source is 'player', but the source is 'api'. &nbsp;
1484803139
vÍnce
Pro
Sheet Author
I'm using our latest code with the changes made for the API update...
1484803182
The Aaron
Pro
API Scripter
Then I've got nothing! =D
1484803354
chris b.
Pro
Sheet Author
API Scripter
is it 'api' in small letters? that is what it looks for: eventInfo.sourceType === 'api' || eventInfo.sourceType === 'player' I changed everything to the above.
1484803501
vÍnce
Pro
Sheet Author
So, it looks like the api script must include the code needed to send source "player" to the sheet in order for sheet workers to recognize the change? &nbsp;
1484806623
Jakob
Sheet Author
API Scripter
Vince said: So, it looks like the api script must include the code needed to send source "player" to the sheet in order for sheet workers to recognize the change? &nbsp; I don't think so, if chris has changed it everywhere and if indeed webworkers simply have a sourceType of 'api' instead of 'player'.
1484808011

Edited 1484808550
vÍnce
Pro
Sheet Author
Thanks Jakob. &nbsp;I can't seem to get any event detection from sheet workers using the script. ;-( I can see the changes that Chris has made, example on("change:recalc1 change:migrate1", TAS.callback(function eventRecaluateSheet(eventInfo) { TAS.debug("caught " + eventInfo.sourceAttribute + " event: " + eventInfo.sourceType); if (eventInfo.sourceType === "player" || eventInfo.sourceType === "api") { checkForUpdate(); } })); but even changing recalc1 "!setattr --sel --recalc1|1" &nbsp;doesn't fire an event.
1484809090
Jakob
Sheet Author
API Scripter
Vince said: Thanks Jakob. &nbsp;I can't seem to get any event detection from sheet workers using the script. ;-( I can see the changes that Chris has made, example on("change:recalc1 change:migrate1", TAS.callback(function eventRecaluateSheet(eventInfo) { TAS.debug("caught " + eventInfo.sourceAttribute + " event: " + eventInfo.sourceType); if (eventInfo.sourceType === "player" || eventInfo.sourceType === "api") { checkForUpdate(); } })); but even changing recalc1 "!setattr --sel --recalc1|1" &nbsp;doesn't fire an event. I would discuss it in the API changes thread; as long as you use version 1.2 of the script and have not deactivated the use of sheet workers, it just calls setWithWorkers(). If that does not fire the event, I cannot do anything about it, you'll have to take it up with Riley ;).
1484809319
vÍnce
Pro
Sheet Author
Sounds good. &nbsp;Thanks
1484842766

Edited 1484842800
When you guys get this all sorted out I hope you can provide a nice example to reference. &nbsp;I'm hoping to map token bars to things like 'Channel Energy' or 'Arcane Pool' points. Thank you again for all your hard work!
1484843220
Jakob
Sheet Author
API Scripter
Sudain said: When you guys get this all sorted out I hope you can provide a nice example to reference. &nbsp;I'm hoping to map token bars to things like 'Channel Energy' or 'Arcane Pool' points. Thank you again for all your hard work! Thanks! So, attributes like spell slots, channel energy pools, or arcane pools usually wouldn't have sheet workers attached to them, so you should be able to modify them freely already. Moreover, for anything token-related, you probably want TokenMod. But I must say I'm a bit confused on what you're actually planning to do here :). Can you elaborate?
1484843403

Edited 1484843544
Ah, maybe I'm doing it wrong. &nbsp;:) The intent is to have the players tokens mapped to their character sheets (or represent those sheets). &nbsp;Then have HP connected to the green bar(arbitrary), and then other class specific features they need to keep track of mapped to the other two bars. &nbsp;Mostly to help me the GM realize that "hey, they are low on resources." or "That barbarian is out of rages for the day, but he said he just raged... &nbsp;interesting..." &nbsp;That's the end goal, and maybe I'm getting my mods mixed up as you said. &nbsp;:D Edit: I am mixing up tokenmod and this one. &nbsp;I do use this one extensively&nbsp;when creating monsters with roll queries. &nbsp;This has saved me a great deal of time creating the monsters, though the sheet updates have reset several key variables (like&nbsp;ac) on monsters over time. &nbsp;But that's an issue for a different thread. &nbsp;:D
1484843823
Jakob
Sheet Author
API Scripter
Sudain said: Ah, maybe I'm doing it wrong. &nbsp;:) The intent is to have the players tokens mapped to their character sheets (or represent those sheets). &nbsp;Then have HP connected to the green bar(arbitrary), and then other class specific features they need to keep track of mapped to the other two bars. &nbsp;Mostly to help me the GM realize that "hey, they are low on resources." or "That barbarian is out of rages for the day, but he said he just raged... &nbsp;interesting..." &nbsp;That's the end goal, and maybe I'm getting my mods mixed up as you said. &nbsp;:D Okay, that sounds like a mix-up ;). I assume that the class resources are in repeating sections, which is why you cannot link them normally? If yes, implementing this properly requires a special-purpose script that keeps your repeating resource counter in sync with some non-repeating attribute (don't know if there is one around somewhere). Neither TokenMod nor ChatSetAttr can do this.
Correct, I can't set them normally. &nbsp;I haven't seen token mod or chatsetattr do it yet so I've just been telling the players to check their tokens when they get on the map.
1484845213
The Aaron
Pro
API Scripter
Sudain said: Ah, maybe I'm doing it wrong. &nbsp;:) The intent is to have the players tokens mapped to their character sheets (or represent those sheets). &nbsp;Then have HP connected to the green bar(arbitrary), and then other class specific features they need to keep track of mapped to the other two bars. &nbsp;Mostly to help me the GM realize that "hey, they are low on resources." or "That barbarian is out of rages for the day, but he said he just raged... &nbsp;interesting..." &nbsp;That's the end goal, and maybe I'm getting my mods mixed up as you said. &nbsp;:D Edit: I am mixing up tokenmod and this one. &nbsp;I do use this one extensively&nbsp;when creating monsters with roll queries. &nbsp;This has saved me a great deal of time creating the monsters, though the sheet updates have reset several key variables (like&nbsp;ac) on monsters over time. &nbsp;But that's an issue for a different thread. &nbsp;:D This is what I use to setup tokens for PCs: !token-mod {{ &nbsp; --on showname&nbsp; &nbsp; &nbsp; light_hassight&nbsp; &nbsp; &nbsp; showplayers_name&nbsp; &nbsp; &nbsp; showplayers_bar1&nbsp; &nbsp; &nbsp; showplayers_bar2&nbsp; &nbsp; &nbsp; showplayers_bar3&nbsp; &nbsp; &nbsp; showplayers_aura1&nbsp; &nbsp; &nbsp; showplayers_aura2 &nbsp; --off isdrawing&nbsp; &nbsp; --set represents|"?{Character Name}" &nbsp; &nbsp; &nbsp; bar1_link|AC &nbsp; &nbsp; bar2_link|Speed &nbsp; &nbsp; bar3_link|HP &nbsp; &nbsp; light_radius|5&nbsp; &nbsp; &nbsp; light_dimradius|=-5&nbsp; }} Does that cover your use case?
For the normally available attributes, yes. &nbsp;For the repeating attributes that a character sheet may or may not have depending on their class abilities, not yet. &nbsp;Or at least I haven't been able to get it to work. &nbsp;I'll try again when I get home tonight. Thank you for the help!
1484848910
The Aaron
Pro
API Scripter
Ah, for repeating, that's unlikely to work. =/ &nbsp;I'll have to experiment with that.
Jakob- the new version of chatsetattr is working very reliably for me so far. Have used it to apply the global bonus for crusaders mantle and bless. Worked every time.
The Aaron said: This is what I use to setup tokens for PCs: !token-mod {{ &nbsp; --on showname&nbsp; &nbsp; &nbsp; light_hassight&nbsp; &nbsp; &nbsp; showplayers_name&nbsp; &nbsp; &nbsp; showplayers_bar1&nbsp; &nbsp; &nbsp; showplayers_bar2&nbsp; &nbsp; &nbsp; showplayers_bar3&nbsp; &nbsp; &nbsp; showplayers_aura1&nbsp; &nbsp; &nbsp; showplayers_aura2 &nbsp; --off isdrawing&nbsp; &nbsp; --set represents|"?{Character Name}" &nbsp; &nbsp; &nbsp; bar1_link|AC &nbsp; &nbsp; bar2_link|Speed &nbsp; &nbsp; bar3_link|HP &nbsp; &nbsp; light_radius|5&nbsp; &nbsp; &nbsp; light_dimradius|=-5&nbsp; }} Very handy! It may be a weird side effect of my sheet (customized from Diana's D&D 3.5 one), but does bar x _link not work for autocalc fields? My armorclass field does not show on the bar after running this. I have changed the above to match the Attribute names in my sheet, and armorclass displays in the sheet. I can manually link the bar to armorclass just fine. My speed and hitpoints fields are just straight text inputs and TokenMod adds them with no problem.
1484916787
The Aaron
Pro
API Scripter
It may not work for auto calc fields. &nbsp;I seem to recall Kryx had found a hack for that a long time ago. &nbsp;I need to revisit that topic.
1485334950
Jakob
Sheet Author
API Scripter
Vince said: Thanks Jakob. &nbsp;I can't seem to get any event detection from sheet workers using the script. ;-( [...] but even changing recalc1 "!setattr --sel --recalc1|1" doesn't fire an event. Any change? Does it work now?
1485335510
vÍnce
Pro
Sheet Author
Still the same. &nbsp;I can see the recalc button change state, but the console log never shows the recalc event detection so sheet workers appear to have no clue anything has changed.
1485346887
Jakob
Sheet Author
API Scripter
Vince said: Still the same. &nbsp;I can see the recalc button change state, but the console log never shows the recalc event detection so sheet workers appear to have no clue anything has changed. That's a shame, it works just fine for me with the Shaped sheet.
It has &nbsp;been lightning fast for me on shaped sheet as well. Flawless
1485359504
vÍnce
Pro
Sheet Author
Jakob said: Vince said: Still the same. &nbsp;I can see the recalc button change state, but the console log never shows the recalc event detection so sheet workers appear to have no clue anything has changed. That's a shame, it works just fine for me with the Shaped sheet. Not sure what's wrong. &nbsp;I believe Chris has made the proper changes and I can see some info in the API log about the PF sheet. &nbsp;There are no errors and the ChatSetattr seems ti be functioning fine other than the sheet not recognizing the event. &nbsp;I'm using 1.2 from github.
1485397405

Edited 1485397439
vÍnce
Pro
Sheet Author
I may have been testing with the wrong version of ChatSetAttr... I think the old and new code both had v1.2 but I noticed the date was newer when I double checked tonight. &nbsp;;-P &nbsp; So now I definitely have the the version I need. &nbsp; Anyhow when I try getting the script to trigger the recalc I noticed the API log has an error about "performance" being undefined. It looks like it's part of TAS. error: "ReferenceError: performance is not defined" "ReferenceError: performance is not defined\n at Array.TAS_CALLSTACK_1 (eval at &lt;anonymous&gt; (eval at &lt;anonymous&gt; (evalmachine.&lt;anonymous&gt;:282:6)), &lt;anonymous&gt;:3:99)\n at self.trigger (evalmachine.&lt;anonymous&gt;:77:37)\n at messageHandler (evalmachine.&lt;anonymous&gt;:285:11)\n at process.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:68:55)\n at emitTwo (events.js:100:13)\n at process.emit (events.js:185:7)\n at handleMessage (internal/child_process.js:695:10)\n at Pipe.channel.onread (internal/child_process.js:440:11)" Thoughts? &nbsp;Is this completely a sheet issue? &nbsp;Thanks
1485400701
The Aaron
Pro
API Scripter
You're using this patch: &nbsp; <a href="https://github.com/shdwjk/TheAaronSheet/pull/1/fil" rel="nofollow">https://github.com/shdwjk/TheAaronSheet/pull/1/fil</a>... I don't believe the performance object exists outside the browser. You could either add some sort of polyfill like: var performance = performance || {now:_.now}; or switch to vanilla TAS.
1485401512

Edited 1485406508
vÍnce
Pro
Sheet Author
Thanks Aaron. &nbsp;I added in the variable line but I'm getting the same error message... callstack = getCallstack(); callstack.shift(); return (function (cb, ctx, cs, lbl) { var ctxref = registerCallstack(cs, lbl); /*jshint -W054 */ var performance = performance || {now:_.now}; return new Function('cb', 'ctx', 'TASlog', "return function TAS_CALLSTACK_" + ctxref + "(){" + "TASlog('Entering: '+(cb.name||'(anonymous function)'));" + "var t0 = performance.now();cb.apply(ctx||{},arguments);var t1 = performance.now();" + "TASlog('Exiting: '+(cb.name||'(anonymous function)')+' (took '+Number(Math.round((t1-t0)+'e3')+'e-3')+' ms)');" + "};")(cb, ctx, log); /*jshint +W054 */ } (callback, context, callstack, label)); API log(the last two lines only happen when I run **!setattr --sel --recalc1|1** &nbsp;) "ReferenceError: performance is not defined" "ReferenceError: performance is not defined\n &nbsp; &nbsp;at Array.TAS_CALLSTACK_1 (eval at &lt;anonymous&gt; (eval at &lt;anonymous&gt; (evalmachine.&lt;anonymous&gt;:282:6)), &lt;anonymous&gt;:3:99)\n &nbsp; &nbsp;at self.trigger (evalmachine.&lt;anonymous&gt;:77:37)\n &nbsp; &nbsp;at messageHandler (evalmachine.&lt;anonymous&gt;:285:11)\n &nbsp; &nbsp;at process.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:68:55)\n &nbsp; &nbsp;at emitTwo (events.js:100:13)\n &nbsp; &nbsp;at process.emit (events.js:185:7)\n &nbsp; &nbsp;at handleMessage (internal/child_process.js:695:10)\n &nbsp; &nbsp;at Pipe.channel.onread (internal/child_process.js:440:11)"
1485401701
The Aaron
Pro
API Scripter
You'll need to add it before TAS.
1485402610
vÍnce
Pro
Sheet Author
Moved the variable line to directly before TAS // Contact: <a href="https://app.roll20.net/users/104025/the-aaron" rel="nofollow">https://app.roll20.net/users/104025/the-aaron</a> var performance = performance || {now:_.now}; var TAS = TAS || (function () { and wow, no errors, but ALL the DEBUG lines from sheet workers get posted to the API console. &nbsp; The browser's console still doesn't show "... Triggering for change:recalc1 VM30:181 TAS: Entering: eventRecaluateSheet VM30:181 DEBUG: caught recalc1 event: player VM30:181 TAS: Exiting: eventRecaluateSheet (took 0 ms) sheetsandboxworker.js?20160926:57 Triggering for change:recalc1_max ..." Which is the normal log output if I actually toggle recalc1 manually.
1485402855
The Aaron
Pro
API Scripter
So, that's to be expected if it runs in the API, right? If you manually change things on the sheet in the game, does it log to the console?
1485403254
vÍnce
Pro
Sheet Author
The Aaron said: So, that's to be expected if it runs in the API, right? If you manually change things on the sheet in the game, does it log to the console? I guess I was expecting to see the same browser's console log output of sheet worker activity regardless if the sheet was triggered by an API script. &nbsp;I assume I was wrong? &nbsp;;-P
1485403784
The Aaron
Pro
API Scripter
Probably. &nbsp;I've not experimented with it, but the whole point of that work was so the API could be "one of the players" with regard to sheet workers. &nbsp;The sheet worker is running in the context of the API (not a browser, Node 6.5 or so) which is why the performance object fails to be located in that function. &nbsp;The practical upshot being that the API Console is your sheet's console when your sheet is running on the API.
1485404262
vÍnce
Pro
Sheet Author
Thanks for leading me to the light Aaron. &nbsp;;-) So now, Pathfinder users can toggle Buffs from a macro! &nbsp;Tested and works! !setattr --sel --repeating_buff_$0_buff-enable_toggle|1 or using rowid !setattr --sel --repeating_buff_-Kap1fyVzj0xX7Fhbq0K_buff-enable_toggle|1 Awesome! Follow up question; I can set values using ChatSetAttr, but what if I simply want to toggle between on/off 1|0?
1485404562
The Aaron
Pro
API Scripter
As in, you just want to reverse the current value? !setattr --sel --repeating_buff_$0_buff-enable_toggle|[[1-(1*@{repeating_buff_$0_buff-enable_toggle})]]
1485406223

Edited 1485406307
vÍnce
Pro
Sheet Author
Yes! &nbsp;Thank you (I had to add " selected| ") It's cool, you're still human... ;-P !setattr --sel --repeating_buff_$0_buff-enable_toggle|[[1-(1*@{selected|repeating_buff_$0_buff-enable_toggle})]]
1485406567
The Aaron
Pro
API Scripter
Hey, I can't do everything for you... =D
1485406634
vÍnce
Pro
Sheet Author
The Aaron said: Hey, I can't do everything for you... =D Who says? &nbsp;You must have been talking to Stephen...
1485406902
The Aaron
Pro
API Scripter
Not in hours! =D
1485413029
Jakob
Sheet Author
API Scripter
Glad it works now! I am slightly confounded though, everything I've uploaded that is titled ChatSetAttr 1.2 had sheet workers included ... anyway, doesn't matter now. Bonus: toggling buffs on multiple characters (untested, but should work). !setattr --evaluate --repeating_buff_$0_buff-enable_toggle|1-%repeating_buff_$0_buff-enable_toggle% Just need to add a targeting option.
1485413405
The Aaron
Pro
API Scripter
Ah yeah, that 1* bit isn't even needed... &nbsp;Man, I'm getting more "human" all the time!
1485414022
vÍnce
Pro
Sheet Author
Thanks guys. &nbsp; @Jakob &nbsp; I'll have to mod that to toggle Conditions on multiple characters. &nbsp;Can't wait to hear the player's all freak out... ;-)
1485550860
Nibrodooh
Pro
Sheet Author
hello, in the latest version of the script from the 1 click install (1.2) I seem to be having trouble with --charid. I get the folowing error causing an error lock. ReferenceError: charid is not defined ReferenceError: charid is not defined at _.each._.each._.chain.map._.chain.filter.charIDList (apiscript.js:1964:41) at eval (eval at (/home/node/d20-api-server/api.js:146:34), :65:16) at Object.publish (eval at (/home/node/d20-api-server/api.js:146:34), :70:8) at /home/node/d20-api-server/api.js:1489:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400 The macros i am trying to get to work are as follows, but i get errors of the sort from any command using --charid !setattr --charid @{character_id} --mod --repeating_item_-&lt;An ID&gt;_qty|-1