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
This post has been closed. You can still view previous posts, but you can't post any new replies.

[Script] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

What do we do with that?
I guess it's just there as a "to-do" for Aaron, right?
1440689502
The Aaron
Pro
API Scripter
Right.  Though feel free to add bugs and feature requests there if you want.  I have most of my scripts in as Milestones, so just choose the right one.
1440695063
vÍnce
Pro
Sheet Author
The Aaron said: Here's one for the losangle 360 bug: &nbsp; <a href="https://github.com/shdwjk/Roll20API/issues/9" rel="nofollow">https://github.com/shdwjk/Roll20API/issues/9</a> Cool. &nbsp;It's now officially a bug. Progress &nbsp;:-P
1440695236
DK Heinrich
Marketplace Creator
Sheet Author
no rush, just as much a reminder for me to remind you as it is a reminder for you to remember it. ;)
1440696955
vÍnce
Pro
Sheet Author
To help isolate the bug; I can set degrees 0 thru 359 on any of the degree-based token properties(rotation, light_angle, light_losangle), but once I try "360" it results to "0". !token-mod --ids @{target|token_id} --set light_losangle|359 = "359" !token-mod --ids @{target|token_id} --set light_losangle|360 = "0" Relative code relating to "360" 103|| transforms = { 104|| degrees: function(t){ 105|| var n = parseFloat(t,10); 106|| if(!_.isNaN(n)) { 107|| n %= 360; 108|| } 109|| return n; 110|| } and 922|| case 'rotation': 923|| case 'light_angle': 924|| case 'light_losangle': 925|| delta=getRelativeChange(token.get(k),f[0]); 926|| if(_.isNumber(delta)) { 927|| mods[k]=(delta%360); 928|| } 929|| break; Hope this helps.
1440702298
The Aaron
Pro
API Scripter
Yeah, I know what the problem is. =D &nbsp;Just need to fix it. &nbsp;The real issue is that for rotation, 360 == 0. &nbsp;For light_angle and light_losangle, the same is not true.
1440702529
vÍnce
Pro
Sheet Author
Simple enough, 359 is close enough in my book for light and los. &nbsp;lol And truthfully, it is.
1440702796
The Aaron
Pro
API Scripter
Yeah, should be relatively easy to clear up. &nbsp;Just getting in to do it. =D
1441481254
The Aaron
Pro
API Scripter
DK Heinrich said: The Aaron said: Token-mob, I like it. =D I was a little afraid that might happen. &nbsp;I'll see if I can add a syntax to only change existing. just checking back on this to see where it is on the list of ten thousand things you have going :) This is done in the latest version. =D
1441481286
The Aaron
Pro
API Scripter
Vince said: To help isolate the bug; I can set degrees 0 thru 359 on any of the degree-based token properties(rotation, light_angle, light_losangle), but once I try "360" it results to "0". !token-mod --ids @{target|token_id} --set light_losangle|359 = "359" !token-mod --ids @{target|token_id} --set light_losangle|360 = "0" Relative code relating to "360" 103|| transforms = { 104|| degrees: function(t){ 105|| var n = parseFloat(t,10); 106|| if(!_.isNaN(n)) { 107|| n %= 360; 108|| } 109|| return n; 110|| } and 922|| case 'rotation': 923|| case 'light_angle': 924|| case 'light_losangle': 925|| delta=getRelativeChange(token.get(k),f[0]); 926|| if(_.isNumber(delta)) { 927|| mods[k]=(delta%360); 928|| } 929|| break; Hope this helps. This is done in the latest version. &nbsp;=D
1441481634
The Aaron
Pro
API Scripter
Update v0.8.10 -- You can now set light_losangle and light_angle to be 360 degrees (Thanks Vince!). !token-mod --set light_losangle|360 Added a syntax to allow incrementing and decrementing status markers without adding statuses on other tokens. Also removes the status marker when the number reaches 0. (Thanks DK Heinrich!). !token-mod --set statusmarkers|?red:-1
WOOHOO!!! Thanks guys!
1441485748
vÍnce
Pro
Sheet Author
Aaron!&nbsp;Aaron!&nbsp;Aaron!&nbsp;Aaron! Thank you sir. &nbsp; Now take some time off for Labor Day!
1441486134
The Aaron
Pro
API Scripter
Time off?? &nbsp;I have scripts to write!!! &nbsp;:)
1441632825
Ziechael
Forum Champion
Sheet Author
API Scripter
I take a week off and you fix things! Right i'm going to take another week off and hope you find a way of making it so that i can use -10 as a light radius option without it reducing the existing value but actually set it to '-10'... combined with the long awaiting (but patiently so) 360 degree update my drop down query light macro will be fully operational! :)
1441633858
The Aaron
Pro
API Scripter
Ha! &nbsp;Did you try putting it in quotes? &nbsp;Might also try two sets, one to 0 and one to -10. Probably I'll have to introduce a new syntax... &nbsp;Maybe =-10
1441634408

Edited 1441636194
Ziechael
Forum Champion
Sheet Author
API Scripter
I remember trying quotes at the time but it just reduced it by 10, i think i tried setting it to 0 first too but maybe i had the syntax wrong to get it to do them one after the other rather than just taking one of the options... my macro is a page or two back i think... i'll try to have a tinker with it later for confirmation. [edit] confirmed that using quotes just 0's out the light radius (not reducing it like a clean -10 does as i first mis-remembered), will try to figure out how to implement two 'set' conditions for my query and try that approach [edit 2] light_dimradius of 0 seems just just leave it blank therefore making the full light radius 'bright' as opposed to stating the dim at 0 as intended.
1441636735
The Aaron
Pro
API Scripter
Update v0.8.11 -- You can now preface a + or - number with an = to explicitly set the field to that value (Thanks Ziechael!) !token-mod --set light_radius|=-10
1441641246
vÍnce
Pro
Sheet Author
Oh yeaaaaaa! &nbsp;Time to update another of Aaron's scripts. &nbsp;Trend setting?
1441641944
The Aaron
Pro
API Scripter
:). Definitely give it your customary "Vinceing"! Zeichael claims it's not working for him. :) In truth, I only tried it on the bars, so it's possible there are some other code paths that are being confused by the =.&nbsp;
1441643156

Edited 1441701488
Ziechael
Forum Champion
Sheet Author
API Scripter
Ziechael swears it is not working for him! ... = values are just ignored and set to NULL for light_dimradius (not sure of others as this is the only one i require negative or 0 values for) But, in the interest of sharing this is what will be achievable once i can get it working as i'm hoping you next release will allow (darnit can never get it to display without parsing the | out even when I layer the html code lol): !token-mod --set ?{Vision|Torch,light_radius&amp;#124;40 light_dimradius&amp;#12420 light_hassight&amp;#124yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;yes|Lantern,light_radius&amp;#124;30 light_dimradius&amp;#124;15 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;yes|Bullseye Lantern,light_radius&amp;#124;120 light_dimradius&amp;#124;60 light_losangle&amp;#124;60 light_hassight&amp;#124;yes light_otherplayers&amp;#124;yes|Hooded Lantern,light_radius&amp;#124;60 light_dimradius&amp;#124;30 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;yes|Sunrod,light_radius&amp;#124;60 light_dimradius&amp;#124;30 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;yes|Candle,light_radius&amp;#124;5 light_dimradius&amp;#124;=0 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;yes|No light source,light_radius&amp;#124;10 light_dimradius&amp;#124;=-10 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;no|Blinded,light_hassight&amp;#124;no light_losangle&amp;#124;360 light_otherplayers&amp;#124;no|Darkvision,light_radius&amp;#124;60 light_dimradius&amp;#124;60 light_hassight&amp;#124;yes light_losangle&amp;#124;360 light_otherplayers&amp;#124;no} That will give a nice little drop down query to quickly set a token/tokens with specific light settings as per the 3.5 rule set (including a custom 'no light source' which gives each player a very dim light to stumble around in the dark with).
1441665023

Edited 1441665072
vÍnce
Pro
Sheet Author
I can confirm that it doesn't post negative numbers to the light/sight linear measurement fields. It does work with the bar values however. +100 on the query Ziechael!
1441676636
The Aaron
Pro
API Scripter
Yeah, I've got the fix on my laptop, but still making my way home from the holiday!
1441680854
The Aaron
Pro
API Scripter
Update v0.8.12 -- Fixed explicit set with = for number and numberText fields. (Thanks again, Ziechael!)
1441684111
The Aaron
Pro
API Scripter
Update v0.8.13 -- Added # as an alternative to | in commands. This makes some macros easier to write. !token-mod --set ?{Feature|Dead, statusmarkers#dead|Red 3, statusmarkers#red:3}
1441684151

Edited 1441701533
The Aaron
Pro
API Scripter
And Z's macro under 0.8.13: !token-mod --set ?{Vision|Torch, light_radius#40 light_dimradius#20 light_hassight#yes light_losangle#360 light_otherplayers#yes|Lantern, light_radius#30 light_dimradius#15 light_hassight#yes light_losangle#360 light_otherplayers#yes|Bullseye Lantern, light_radius#120 light_dimradius#60 light_losangle#60 light_hassight#yes light_otherplayers#yes|Hooded Lantern, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Sunrod, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Candle, light_radius#5 light_dimradius#=0 light_hassight#yes light_losangle#360 light_otherplayers#yes|No light source, light_radius#10 light_dimradius#=-10 light_hassight#yes light_losangle#360 light_otherplayers#no|Blinded, light_hassight#no light_losangle#360 light_otherplayers#no|Darkvision, light_radius#60 light_dimradius#60 light_hassight#yes light_losangle#360 light_otherplayers#no}
1441685026
The Aaron
Pro
API Scripter
Definitely let me know if using # in this way causes an issue. I can change it to an option without much trouble.&nbsp;
1441685522
vÍnce
Pro
Sheet Author
That works a like a charm. &nbsp;Query on. &nbsp;Thanks for pounding on this Aaron.
1441685747
The Aaron
Pro
API Scripter
Octothorpes for everyone! :)
1441685899
vÍnce
Pro
Sheet Author
The Aaron said: Octothorpes for everyone! :) That was a nice change. &nbsp;Thanks
1441686271
The Aaron
Pro
API Scripter
Oh, see I thought you were making a pun with " pound ing on". :) Yeah, could be handy. Certainly easier than changing all the extra | to &amp;#125. (Actually, the necessary code change was easier than that would have been!)
The Aaron said: And Z's macro under 0.8.13: !token-mod --set ?{Vision| Torch, light_radius#40 light_dimradius#20 light_hassight#yes light_losangle#360 light_otherplayers#yes|Lantern, light_radius#30 light_dimradius#15 light_hassight#yes light_losangle#360 light_otherplayers#yes|Bullseye Lantern, light_radius#120 light_dimradius#60 light_losangle#60 light_hassight#yes light_otherplayers#yes|Hooded Lantern, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Sunrod, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Candle, light_radius#5 light_dimradius#=0 light_hassight#yes light_losangle#360 light_otherplayers#yes|No light source, light_radius#10 light_dimradius#=-10 light_hassight#yes light_losangle#360 light_otherplayers#no|Blinded, light_hassight#no light_losangle#360 light_otherplayers#no|Darkvision, light_radius#60 light_dimradius#60 light_hassight#yes light_losangle#360 light_otherplayers#no} Could this same macro be done as API buttons, or does that not function with the query?
1441701873
Ziechael
Forum Champion
Sheet Author
API Scripter
Gozer the Gozerian said: The Aaron said: And Z's macro under 0.8.13: &lt;macro removed for space&gt; Could this same macro be done as API buttons, or does that not function with the query? I'm sure it could,&nbsp; OldSchoolChris has already done something to that effect earlier in the thread which could be easily updated to suit your needs i reckon. (His code is 5 posts later than the link provided). I haven't played around with query/button combos to be honest but i'm sure it can be done with the correct html code nesting?
1441702137
Ziechael
Forum Champion
Sheet Author
API Scripter
Ok, if i had a seal of approval I would apply it now, my needs are met and I'm a happy DM, thanks :)
1441716066
The Aaron
Pro
API Scripter
Gozer the Gozerian said: Could this same macro be done as API buttons, or does that not function with the query? Yup! This should do it: [Set Vision](!token-mod --set &amp;#63;{Vision| Torch, light_radius#40 light_dimradius#20 light_hassight#yes light_losangle#360 light_otherplayers#yes|Lantern, light_radius#30 light_dimradius#15 light_hassight#yes light_losangle#360 light_otherplayers#yes|Bullseye Lantern, light_radius#120 light_dimradius#60 light_losangle#60 light_hassight#yes light_otherplayers#yes|Hooded Lantern, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Sunrod, light_radius#60 light_dimradius#30 light_hassight#yes light_losangle#360 light_otherplayers#yes|Candle, light_radius#5 light_dimradius#=0 light_hassight#yes light_losangle#360 light_otherplayers#yes|No light source, light_radius#10 light_dimradius#=-10 light_hassight#yes light_losangle#360 light_otherplayers#no|Blinded, light_hassight#no light_losangle#360 light_otherplayers#no|Darkvision, light_radius#60 light_dimradius#60 light_hassight#yes light_losangle#360 light_otherplayers#no} --ids &amp;#64;{target|token_id} ) It will make a button which will prompt for which token, then prompt for what light source type. &nbsp;You can omit the --ids ... part if you don't want the target function and instead want to affect the selected tokens.
1441716108
The Aaron
Pro
API Scripter
Ziechael said: Ok, if i had a seal of approval I would apply it now, my needs are met and I'm a happy DM, thanks :) That just seems too easy... what about CharMod? &nbsp;I mean, if you don't really want it... &nbsp;=D
The Aaron said: Gozer the Gozerian said: Could this same macro be done as API buttons, or does that not function with the query? Yup! This should do it: (snip) Thanks!
1441718485
Ziechael
Forum Champion
Sheet Author
API Scripter
The Aaron said: Ziechael said: Ok, if i had a seal of approval I would apply it now, my needs are met and I'm a happy DM, thanks :) That just seems too easy... what about CharMod? &nbsp;I mean, if you don't really want it... &nbsp;=D Hmmm... CharMod?? What's that... sounds intriguing but surely it can't beat the functionality of TokenMod or Ammo and other such jewels??
1441718606
The Aaron
Pro
API Scripter
Hahahahaha, Touché! &nbsp;=D
1441734175
DK Heinrich
Marketplace Creator
Sheet Author
Looks great - I will mess with it as soon as I get caught up from long weekend away from computer. Thanks for the changes!
1441767342
vÍnce
Pro
Sheet Author
Ziechael said: Ok, if i had a seal of approval I would apply it now, my needs are met and I'm a happy DM, thanks :) Aaron gets mine. &nbsp;:-)
1441768308
The Aaron
Pro
API Scripter
Oh man, I thought you reserved that for Stephen's scripts! &nbsp;He's gonna be so jealous! &nbsp;=D
1441786090
Ziechael
Forum Champion
Sheet Author
API Scripter
Vince said: Ziechael said: Ok, if i had a seal of approval I would apply it now, my needs are met and I'm a happy DM, thanks :) Aaron gets mine. &nbsp;:-) ^^ the only reason i didn't create my own was that i didn't want to infringe on your intellectual property Vince ;)
1441796805
The Aaron
Pro
API Scripter
You know, technically he didn't create his own either. :)
1441797245
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Everyone slow down...&nbsp; We can't have the VSoA award becoming a participation trophy.
I'm doing the API buttons thing, and my macro for turning off all light sources for a token keeps crashing the API. &nbsp;Here's my macro: [LightsOut](!token-mod --set light_radius| light_dimradius| light_angle|360 light_otherplayers|no) Here's the error I'm getting: Can someone help?
1442235677
The Aaron
Pro
API Scripter
hmm... looks like I've introduced a bug with my most recent change. &nbsp;I'll take a look tonight and get it fixed.
1442236194
The Aaron
Pro
API Scripter
OK, nm, I looked at it and fixed it now. =D This is the macro you should use. &nbsp;The other one will no longer crash the API, but it won't work either. &nbsp;0 light radius turns it off: [Lights Out](!token-mod --set light_radius|0 light_dimradius|0 light_angle|360 light_otherplayers|no)
1442236290
The Aaron
Pro
API Scripter
Update v0.8.14 -- Fixed the bug causing a crash for empty arguments. (Thanks Gozer the Gozerian!)