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 Update] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

The Aaron said: There isn't currently, I'm afraid.  It's on my list to figure out a way to do that, but hasn't gotten done yet. Look at GroupInit, you will understand it, i certainly don't.
1612087769

Edited 1612087784
The Aaron said: There isn't currently, I'm afraid.  It's on my list to figure out a way to do that, but hasn't gotten done yet. I tried to do random HP on many tokens with token-mod, but of course encountered the same issue: only the first value has been applied to all. I am using VTT Enhancment Suite. There is a feature to apply HD to the bars based on the hp-formula, wich works. Maybe it's possible to steal the code there. ;-) Anyhow: using VTT Enhancer is a good workaround for all. It's a great chrome/firefox extension.
1612111374
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
al e. said: The Aaron said: There isn't currently, I'm afraid.  It's on my list to figure out a way to do that, but hasn't gotten done yet. Look at GroupInit, you will understand it, i certainly don't. I would hope he could... ;)
1612134259
The Aaron
Roll20 Production Team
API Scripter
keithcurtis said: al e. said: The Aaron said: There isn't currently, I'm afraid.  It's on my list to figure out a way to do that, but hasn't gotten done yet. Look at GroupInit, you will understand it, i certainly don't. I would hope he could... ;) Yeah, it's largely a question of what syntax to use.  GroupInitiative has the advantage that all of the potential attribute references are configured ahead of time.  TokenMod needs to take them on the fly, which is where you need a syntax to tell it what you want.  @{selected|} gets evaluated on the client side before sending to the API, so something else is needed.
Good afternoon "The Aaron." I'm tracking down API's that need to be updated. Please tell me token-mod's latest version and if it's automatically added to the 'one' click install. Or, now or in the future, do I cut and paste?  Also, while looking allover Githum for this information, I see you have quite a few API's in the public domain. Is there a place (besides GitHub)  where I can view them - maby include them in my API bag of holding? Larry
1612818492

Edited 1612818516
The Aaron
Roll20 Production Team
API Scripter
Any script I release that is in the 1-click is always the latest version (with whatever lead time there is for Roll20 to accept the pull request). All the full scripts I have publicly released are current and up to date here:&nbsp; <a href="https://github.com/shdwjk/Roll20API" rel="nofollow">https://github.com/shdwjk/Roll20API</a> Here's all the version information for all of them: Project Flags Dev Ver Prod Ver Release Ver Last Update Status APIHeartBeat SDO 0.4.2 0.4.2 0.4.2 Nov 8th [Utility] APISelection SDO 0.1.0 0.1.0 0.1.0 2018-07-16 [Utility] Ammo SDO 0.3.11 0.3.11 0.3.11 2020-06-12 [Character] AnnounceRoll SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. Base64 SDO 0.3.2 0.3.2 0.3.2 2019-12-16 [Utility] BashDice SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. Bet SD. 0.1.4 0.1.4 &lt;missing&gt; 2017-03-24 Update Release. BounceTokens SDO 0.1.3 0.1.3 0.1.3 Dec 29th [Tokens] Bump SDO 0.2.19 0.2.19 0.2.19 2020-05-05 [Tokens] CharUtils SD. 0.6.4 0.6.4 &lt;missing&gt; 2018-07-22 Update Release. CleanAbilities SD. 0.1.2 0.1.2 &lt;missing&gt; 2017-03-24 Update Release. ColorEmote SDO 0.1.9 0.1.9 0.1.9 2018-08-08 [Chat] ColorNote SDO 0.2.3 0.2.3 0.2.3 Nov 26th [Chat] CthulhuTechDice SD. 0.1.13 0.1.13 &lt;missing&gt; 2017-05-16 Update Release. DarknessClosingIn SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. DiceTests SD. 0.1.4 0.1.4 &lt;missing&gt; 2017-04-13 Update Release. DryErase SDO 0.1.8 0.1.8 0.1.8 2017-03-24 [Maps &amp; Drawing] Emas SDO 0.8.4 0.8.4 0.8.4 Dec 29th [Chat] Escalation SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. Facing SDO 0.1.6 0.1.6 0.1.6 Dec 29th [Tokens] FateDots SDO 0.2.3 0.2.3 0.2.3 Dec 29th [System Toolbox] GMAura SDO 0.1.0 0.1.0 0.1.0 2019-09-02 [Tokens] GroupInitiative SDO 0.9.35 0.9.35 0.9.35 Jan 26th [Character] ImperialCalendar SDO 0.1.2 0.1.2 0.1.2 2018-07-22 [Utility] InitiativeAssistant SDO 0.1.6 0.1.6 0.1.6 Dec 29th [Utility] IsGM SD. 0.7.2 0.7.2 &lt;missing&gt; 2017-03-28 Update Release. IsGreater SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. MD5Sum SDO 0.1.0 0.1.0 0.1.0 Nov 6th [Utility] ManualAttribute SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. MapLock SDO 0.4.6 0.4.6 0.4.6 2020-05-22 [Tokens] MapSnap SD. 0.1.4 0.1.4 &lt;missing&gt; 2017-03-30 Update Release. Mark SDO 0.3.5 0.3.5 0.3.5 2018-01-02 [Tokens] Measure SDO 0.3.3 0.3.3 0.3.3 2018-06-30 [Utility] MonsterHitDice SDO 0.3.9 0.3.9 0.3.9 Oct 12th [Tokens] MotD SDO 0.2.12 0.2.12 0.2.12 2019-06-25 [Chat] MovePlayers SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. MutantYearZero SDO 0.1.11 0.1.11 0.1.11 2019-02-05 [System Toolbox] NoteLog SDO 0.1.3 0.1.3 0.1.3 2020-05-08 [Utility] Observer SDO 0.1.6 0.1.6 0.1.6 2020-01-07 [Character] PCPP SDO 0.3.3 0.3.3 0.3.3 2018-07-07 [Utility] PeekCard SDO 0.1.0 0.1.0 0.1.0 2019-01-01 [Utility] PetTheDog SD. 0.1.0 0.1.0 &lt;missing&gt; 2020-01-09 Update Release. RandomDepth SD. 0.3.1 0.3.1 &lt;missing&gt; 2015-03-29 Update Release. RandomRotate SDO 0.2.3 0.2.3 0.2.3 2019-08-05 [Tokens] RecursiveTable SDO 0.2.5 0.2.5 0.2.5 2020-06-26 [Utility] ScaleOnAdd SDO 0.1.3 0.1.3 0.1.3 2018-01-11 [Tokens] Search SDO 0.1.1 0.1.1 0.1.1 2017-07-11 [Utility] SizeLock SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. SpellLevel5e SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. SpinTokens SDO 0.4.3 0.4.3 0.4.3 Sep 7th [Tokens] TableExport SDO 0.2.4 0.2.4 0.2.4 2020-07-02 [Utility] TableTokenSizer SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. Tagmar SDO 0.1.3 0.1.3 0.1.3 2020-03-25 [System Toolbox] TempHPAndStatus SD. 0.4.1 0.4.1 &lt;missing&gt; 2015-03-29 Update Release. Tile SD. 0.3.1 0.3.1 &lt;missing&gt; 2015-03-29 Update Release. TokenCondition SDO 0.1.2 0.1.2 0.1.2 Dec 16th [Tokens] TokenLock SDO 0.2.8 0.2.8 0.2.8 2020-05-22 [Tokens] TokenMod SDO 0.8.63 0.8.63 0.8.63 Jan 20th [Tokens] TokenNameNumber SDO 0.5.12 0.5.12 0.5.12 2019-07-20 [Tokens] Torch SDO 0.8.13 0.8.13 0.8.13 Dec 29th [Dynamic Lighting] TotalMana SD. 0.1.3 0.1.3 &lt;missing&gt; 2015-10-14 Update Release. TurnMarker1 SD. 1.3.10 1.3.10 &lt;missing&gt; 2020-07-30 Update Release. Twins SD. 0.2.1 0.2.1 &lt;missing&gt; 2015-03-29 Update Release. UDLWindows SDO 0.1.1 0.1.1 0.1.1 Dec 29th [Dynamic Lighting] UniversalVTTImporter SDO 0.1.6 0.1.6 0.1.6 Dec 30th [Utility] UsePower SD. 0.4.2 0.4.2 &lt;missing&gt; 2017-03-30 Update Release. Walls SDO 0.3.6 0.3.6 0.3.6 2019-11-17 [Dynamic Lighting] WeaponArcs SDO 0.1.3 0.1.3 0.1.3 2020-08-04 [Tokens] WeightedDice SD. 0.3.2 0.3.2 &lt;missing&gt; 2015-09-22 Update Release. WildDice SDO 0.3.5 0.3.5 0.3.5 Nov 27th [System Toolbox] ZombieDice SD. 0.4.1 0.4.1 &lt;missing&gt; 2015-03-29 Update Release. libTokenMarkers SDO 0.1.1 0.1.1 0.1.1 Dec 29th [Utility] The "Prod Ver" column is the version currently in my github repo, the "Release Ver" is the version currently in Roll20's repo.&nbsp; The O in the Flags column indicates it is in the 1-click installs.&nbsp; The category is listed in the Status column in [ ].
Hi Aaron, is there a place that describes what each of those scripts does? &nbsp;For example, I didn’t recognize “API Selection”, so I clicked on it from within GitHub, and I can see the code, but I don’t see a ReadMe or other description. &nbsp;Am I overlooking it due to not being familiar with GitHub (or being on the mobile version on my phone), or is it just a snippet you wrote up for yourself and so didn’t take the time to document (which is totally understandable!)? Thanks, as always. The size of that list truly shows your talents and generosity in sharing them all with us!
1612880419

Edited 1612880623
The Aaron
Roll20 Production Team
API Scripter
It's a script that provides a selection system for API scripts.&nbsp; I wrote it with Scott at one point a few years ago, but I don't know that it's been much adopted.&nbsp; Tim R.'s SelectionManager is probably a better system to use for aspiring scripters.&nbsp; Edit: though looking at this again, this is more about saving named lists of ids, so you might use it for defining who is your party, or various encounter groups.&nbsp; Basically, I guess it's a bit different than Tim's SelectionManager, but not really used by anything currently. Here's the docs, I really should get those into the public repos... APISelection adds a simple interface for other scripters to use when creating scripts that operate on a persisted selection of objects, as well as sharing a list of selected objects across multiple scripts. At its heart, it is nothing more than a mapping from a&nbsp; string &nbsp;key, to an array of&nbsp; string s, with an interface to make manipulating those arrays easy. Public Interface APISelection has 5 public functions: getList( id ) &nbsp;-- Returns an array which represents that&nbsp; id . It will always return an array, even if nothing has been saved for that&nbsp; id . The returned array will always only contain strings. Manipulations of the returned array will not change the stored array. setList( id , list ) &nbsp;-- Sets the array for an&nbsp; id . The current array for the id will be replaced. Returns a copy of the stored array, as with&nbsp; getList( id ) . Only one copy of a value in the&nbsp; list &nbsp;will be retained, duplicates are removed. deleteList( id ) &nbsp;-- Removes the array for an&nbsp; id . Returns the emtpy array&nbsp; [] . removeFromList( id, list ) &nbsp;-- Removes the values in the&nbsp; list &nbsp;argument from the stored array for the&nbsp; id . Returns a copy of the stored array with the&nbsp; list &nbsp;arguments removed as with&nbsp; getList( id ) . addToList( id , list ) &nbsp;-- Adds the contents of the&nbsp; list &nbsp;argument to the stored array for the&nbsp; id . All duplicate values are removed. Returns a copy of the stored array with the&nbsp; list &nbsp;arguments added as with&nbsp; getList( id ) . Example Use on('ready',()=&gt;{ APISelection.setList( 'party-characters', findObjs({type:'character'}) .filter((c)=&gt;c.get('controlledby').length) .map(c=&gt;c.id) ); // ... let partyCharIds = APISelection.getList('party-characters'); let partyTokens = findObjs({type:'graphic'}) .filter(t=&gt;partyCharIds.includes(t.get('represents'))); // ... etc }); Commands !api-selection Lists the current selection lists and their values. Mainly useful for scripters inspecting what is happening.
Hi Aaron, I've only just started using API scripts - both using the library ones and writing my own basic ones. You script authors have produced some awesome scripts! So I have a question about playerscanIDs in the tokenmod script.... I have written an ability macro for one of my players so it launches a spell effect (for the Hex spell) towards a selected target, and then calls tokenmod in order to put a condition icon on that target (it also puts an aura on the target so its obvious there's a condition on it): /fx beam-death @{selected|token_id} @{target|token_id} !token-mod --on showplayers_aura1 --set aura1_radius#4 aura1_color#FFFFFF --set statusmarkers#!death-zone --ids @{target|token_id}&nbsp; This all works fine for me as the DM, but obviously wont work for the player unless I turn on playerscanIDs. My ideal would be for me to be able to have this turned on by default, without having to remember to run the script with playerscanIDs|on at the start (does this setting persist between game sessions?). The reason this is a (minor) issue is that I create all my scrips, macros, characters etc, etc in one "base" game, then copy them (with the transmogrifier/exporting macro json files) into any new game I may create for groups, so I would need to remember to turn on playerscanIDs every time I create a new game and copy these scripts into it (I'd probably get round this by creating a "RunMeOnNewGame") script that I as the DM can run when I create a new game, which sets this toggle up (and anything else I may come across)). Another alternative (not tested) is for me to include the playerscanIDs|on in the above macro, but I am guessing this would fail for a player? It also will pop a whispered chat every time it is used by the player to tell me that playerscanIDs has been set - a minor inconvenience. So this is really a minor issue, but I wondered if there was a way to have the playerscanIDs on by default?
1613231986
The Aaron
Roll20 Production Team
API Scripter
The setting is persisted, so you only need to run it once on a given game. I'll think on how I could make this easier for managing multiple games.&nbsp;
After some recent updates to UDL, I started testing some of macros to interact with a token's UDL settings. By and large, everything is working great and I'm finally excited to use UDL. However, I'm encountering an issue with TokenMod, UDL, and actually results. When I use TokenMod to render a token blind, the token's settings are updated but the token continues to have vision. !token-mod --off night_vision bright_vision If I go into the token's settings to manually disable vision, the token actually loses vision. Additionally, if I use TokenMod to resume vision to a blinded token, a similar effect occurs. The token's settings are update to reflect the TokenMod command but the token doesn't actually regain sight. Also when this occurs, there seems to be a muted, or dulled visual effect that occurs on the map. I've found that seems to be related to night vision tint. If I incorporate a transparency command into my macro to regain sight, the token's night vision tint is updated in the settings but nothing actually occurs. !token-mod --on night_vision bright_vision --set night_vision_tint|transparent Similarly if I go into the token's settings to manually toggle a token's vision or night vision tint, everything seems to work properly.
1613673275
The Aaron
Roll20 Production Team
API Scripter
This is actually a known bug.&nbsp; Corey was rolling out a fix for it in Dec, but it had issues and he had to revert it.&nbsp; I'll check the status on that now.
The Aaron said: This is actually a known bug.&nbsp; Corey was rolling out a fix for it in Dec, but it had issues and he had to revert it.&nbsp; I'll check the status on that now. At least it's not me. :-P Thank you for checking and thank you again for all the amazing support you've provided the community.
Is there a way to use TokenMod to interact with a token's low light brightness? If so, what's the correct syntax?
1613674134

Edited 1613674374
The Aaron
Roll20 Production Team
API Scripter
That hasn't been provided to the API yet, but I've been asking for it since it was on Dev last week. Edit: Actually, it looks like that IS exposed.&nbsp; I'll get that out tonight!
Thanks, Aaron! &nbsp;With the announced upcoming sunset of legacy dynamic lighting, I’m very hopeful you get access to everything you need to get UDL feature parity for TokenMod.
1613678120
The Aaron
Roll20 Production Team
API Scripter
Me too! =D&nbsp; The Devs are also motivated to do that as well. =D
1613711000
The Aaron
Roll20 Production Team
API Scripter
Update v0.8.84 -- Added dim_light_opacity (and low_light_opacity) percentage fields. Percentage Percentage values can be a floating point number between 0 and 1.0, such as&nbsp; 0.35 , or an integer number between 1 and 100. Available Percentage Properties: dim_light_opacity Setting the low light opacity to 30%: !token-mod --set dim_light_opacity|30 !token-mod --set dim_light_opacity|0.3
1613772976
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
I redid this macro for my Pathfinder game and broke it. !token-mod {{?{What Type of Vision |None/Blind, --set has_bright_light_vision#no emits_bright_light#no bright_light_distance#0 has low_light_vision#no emits_low_light#no low_light_distance#0 has_night_vision#no has night_vision_distance#0 night_vision_tint #transparent |Darkvision, set has_night_vision#yes has night_vision_distance#0 night_vision_tint ##EEEEEE has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 |Lowlight, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#200 |Normal, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#100 |}}} Need a little help.
Not sure if I missed it anywhere, but is there a command for toggling Daylight_Mode in UDL?
1613883473
The Aaron
Roll20 Production Team
API Scripter
That's a page setting, not a token setting, so it's kind of thematically wrong to put it in TokenMod. I can write you something for that though.&nbsp;
1613919899
The Aaron
Roll20 Production Team
API Scripter
Actually, looks like I already wrote something:&nbsp;<a href="https://app.roll20.net/forum/post/9719344/script-snippet-toggledaylight-turn-daylight-mode-on-off-or-toggle-it-for-ldl-or-udl-on-the-current-page" rel="nofollow">https://app.roll20.net/forum/post/9719344/script-snippet-toggledaylight-turn-daylight-mode-on-off-or-toggle-it-for-ldl-or-udl-on-the-current-page</a>
1613921291
The Aaron
Roll20 Production Team
API Scripter
SᵃᵛᵃǤᵉ said: I redid this macro for my Pathfinder game and broke it. !token-mod {{?{What Type of Vision |None/Blind, --set has_bright_light_vision#no emits_bright_light#no bright_light_distance#0 has low_light_vision#no emits_low_light#no low_light_distance#0 has_night_vision#no has night_vision_distance#0 night_vision_tint #transparent |Darkvision, set has_night_vision#yes has night_vision_distance#0 night_vision_tint ##EEEEEE has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 |Lowlight, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#200 |Normal, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#100 |}}} Need a little help. So, you've got 3 places where it says "has " instead of "has_": !token-mod {{?{What Type of Vision |None/Blind, --set has_bright_light_vision#no emits_bright_light#no bright_light_distance#0 has_low_light_vision#no emits_low_light#no low_light_distance#0 has_night_vision#no has_night_vision_distance#0 night_vision_tint #transparent |Darkvision, set has_night_vision#yes has_night_vision_distance#0 night_vision_tint ##EEEEEE has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 |Lowlight, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#200 |Normal, --set has_bright_light_vision#yes emits_bright_light#no bright_light_distance#0 emits_low_light#no low_light_distance#0 light_multiplier#100 }}} Other than that, it seems fine.&nbsp; You aren't setting any light radii, so it's just going to see external lights. Note that the light_multipler field is for LDL, and has no effect on UDL light.&nbsp; The UDL: Advanced Settings: Light Multiplier field is not exposed to the API yet.
The Aaron said: That's a page setting, not a token setting, so it's kind of thematically wrong to put it in TokenMod. I can write you something for that though.&nbsp; Duh, I should've guessed that. The Aaron said: Actually, looks like I already wrote something:&nbsp; <a href="https://app.roll20.net/forum/post/9719344/script-snippet-toggledaylight-turn-daylight-mode-on-off-or-toggle-it-for-ldl-or-udl-on-the-current-page" rel="nofollow">https://app.roll20.net/forum/post/9719344/script-snippet-toggledaylight-turn-daylight-mode-on-off-or-toggle-it-for-ldl-or-udl-on-the-current-page</a> Still coming through, thanks Aaron!
First, I LOVE tokenmod. it helps so much with lighting.&nbsp; Quick Question, it will take a bit to explain. I will post up to the Roll20 Forms too. As Legacy Lighting is going away I find myself updating light sources on maps. I need to go in and turn off Legacy Lighting and add Updated Dynamic Lighting )UDL). The UDL is easy with the API TokenMod. I put some extra stuff in the script just in case I played with UDL on the token before and I need to turn off some feature. !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#15 low_light_distance#15 directional_bright_light_center#0 directional_bright_light_total#0 Finally the questions. Is there an value in the API Support for Legacy Lighting so I can use a script to turn off the All Players See Light and Has Sight check boxes in the Legacy Lighting?
1614277267
The Aaron
Roll20 Production Team
API Scripter
I could certainly write a script that does that pretty quickly, but honestly, you should be able to ignore that setting as it will just silently go away when LDL is sunset.&nbsp; Even before then, it won't be used if the page has UDL enabled.
The Aaron said: I could certainly write a script that does that pretty quickly, but honestly, you should be able to ignore that setting as it will just silently go away when LDL is sunset.&nbsp; Even before then, it won't be used if the page has UDL enabled. I felt like I had issues if both UDL and LDL were enabled on a page or token. Honestly I have not played with it for a couple months, so perhaps the issues I was seeing have been fixed.&nbsp;
1614281292
The Aaron
Roll20 Production Team
API Scripter
Well... UDL with the API is still a bit broken, but they're working on it.&nbsp; If you turn on UDL on a page, it will turn off LDL.
1614282330

Edited 1615842143
I have been writing macros to make UDL more dynamic, so it is easy to adjust it on the fly. I thought I would share the macros here. I play D&amp;D 5e so the values all relate to 5e. These are all macros to change Token settings.&nbsp; NOTE: I found some issue when I was playing with directional light, I had to turn it off when switching a token from having directional light to not having it. So that is added to these macros.&nbsp; To use these macros, first select a token, then run the macro.&nbsp; Torch - Turn on lighting for 20 bright and 20 dim.&nbsp; !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#20 low_light_distance#20 directional_bright_light_center#0 directional_bright_light_total#0 Snuff - turn off all visible light.&nbsp; !token-mod --off emits_bright_light emits_low_light --set directional_bright_light_center#0 directional_bright_light_total#0 Hooded-Lantern-Open - 30 bright, 30 dim !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light --set bright_light_distance#30 low_light_distance#30&nbsp; Hooded-Lantern-Closed - a closed lanters gives off 5 feet dim.&nbsp; !token-mod --on emits_low_light --off emits_bright_light has_directional_bright_light --set low_light_distance#5 bright_light_distance#0 Bull - Bullseye lantern, I found I like 10 degrees of light, !token-mod --on emits_bright_light has_directional_bright_light --off emits_low_light --set bright_light_distance#120 low_light_distance#60 directional_bright_light_center#90 directional_bright_light_total#10 Darkvison-60 &nbsp; !token-mod --on has_night_vision !token-mod --set night_vision_distance#60 Darkvison-120 !token-mod --on has_night_vision --set night_vision_distance#120 Darkvison-Off !token-mod --off has_night_vision --set night_vision_distance#0 Light-Dynamic - I found that at times I might want to dynamically change the bright and dim light. This pops up a questions, first asking for bright then dim light distances.&nbsp; !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#?{Bright} low_light_distance#?{Dim} directional_bright_light_center#0 directional_bright_light_total#0 Putting it all together into one button .&nbsp; I set all of these to be token actions, but then my list of token actions takes up way too much screen space. I put all but the Dynamic one into a single menu button. I did it by having a macro that calls the other macos. Why not just put the commands in the menu macro. I have two menus, one for the DM and one for the players. I do not give the players the Darkvison settings, they do not need them very often, so I do it if they need it. But my players can say I light a torch or open my bullseye lantern and use the menu to change the settings for their token.&nbsp; All the meacor start with EBI-DL. The EBI is a play on words, and the DL for for Dynamic Lighting. This keeps all the macros together in the list of macros and easy to identify as ones I wrote.&nbsp; Light-Menu-DM ?{Light|Snuff,#EBI-DL-Snuff |Torch,#EBI-DL-Torch |Bullseye,#EBI-DL-Bull |Hooded Lantern Open,#EBI-DL-Hooded-Lantern-Open |Hooded Lantern Closed,#EBI-DL-Hooded-Lantern-Closed |Dark-60,#EBI-DL-Darkvison-60 |Dark-120,#EBI-DL-Darkvison-120 |No Darkvison,#EBI-DL-Darkvison-Off } The first stuff is to pop up the question with Light, then the basic format of the choices are&nbsp; |Snuff,#EBI-DL-Snuff | to start a choice What you want it to say in the menu , (comma) # the name of the macro a blank space, the space at the end is important. No other spaces.&nbsp; I hope others find this useful. Bob
Thank you, Bob! &nbsp;I haven’t made the transition to UDL yet, so I’m going to copy your macro to replace my current LDL TokenMod light macro. Thanks for saving me a bunch of time making my own!
1614545458

Edited 1614545690
There's something I'm not getting and every time I search for an answer, the forums time out. I'm trying to set the name of a token, but the API seems to ignore the complete name, taking only the name up to the first space character in the name. Edit: Nevermind, realized you could place the quotation marks around a reference.
Joe said: Thank you, Bob! &nbsp;I haven’t made the transition to UDL yet, so I’m going to copy your macro to replace my current LDL TokenMod light macro. Thanks for saving me a bunch of time making my own! It makes me happy to know I helped one or more people.&nbsp;
The Aaron said: Well... UDL with the API is still a bit broken, but they're working on it.&nbsp; If you turn on UDL on a page, it will turn off LDL. I had a page with UDL enabled. Nothing seemed to be working, I have to enable LDL, then turn it off, then turn on UDL. After that it worked great. Perhaps all I needed to do was turn off UDL and turn it back on, will never know.&nbsp; Bob
Hi All, do you know if the "dimming" effect is exposed yet?&nbsp; I'd like to set that in lieu of none, as it seems to give a better overall aesthetic to all lighting.
How does one get the URL of images in their art library - specifically, in a folder of uploaded images for use with Tokenmod's ability to create multi-sided tokens? I do know about zooming on a graphic on the tabletop, right-clicking and inspecting the zoomed image to get the URL - but with potentially 200-500 cards - that's a lot of work. I am wanting to create a multi-sided token to use for a "choose your own adventure" game where the token represents a deck of cards and if the game says, "grab card# 231" I can use Tokenmod to select side 231.&nbsp; I'm having to do this because Roll20s card deck system does not allow picking out a specific card from a deck.
1615137284
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You can use the dealer script to deal out a card by name: !deal --[give,take] [#] --[deck name]|[Card Name] You can find it in one click.
How did I miss that one? However, it doesn't answer my question (if someone could chime in, that would be appreciated), It does look like it will address my need, tho'. Especially with Roll20s bulk deck building feature. I'll have to give it a try. Thanks, Keith
1615166142
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Doug E. said: However, it doesn't answer my question (if someone could chime in, that would be appreciated), Yeah, I was hoping it would circumvent the need, given your reason for asking: Doug E. &nbsp;said: I'm having to do this because Roll20s card deck system does not allow picking out a specific card from a deck. To answer your question, the API does not have access to your user library and cannot read lists of tokens or folder structure from it. It can read the token image sources already attached to a rollable token.
I'm probably going about this all the wrong way - But basically I want to use TokenMod to do the settings to change Monster/NPC hit points scaled based on the maximum possible for them via npc_hpformula. Hung up on how to get the Maximum calculated - any attempt gets me a roll of the npc_hpformula attribute which is not what I'm after. I have used the setup monster tokens. I want to remove the work for me to adjust constantly my setups for party strengths because of different party sizes/levels on one shots and the need to just increase difficulty on my hard cover campaigns. Im setting up my macro to click on a token - read the npc_hpformula attribute - calc the max and apply a rounded hp from a queried percentage entered by me depending on the situation.
1615177795
The Aaron
Roll20 Production Team
API Scripter
Doug E. said: How did I miss that one? However, it doesn't answer my question (if someone could chime in, that would be appreciated), It does look like it will address my need, tho'. Especially with Roll20s bulk deck building feature. I'll have to give it a try. Thanks, Keith The easiest way (the way I do it) is to drag the image onto the map, then just collect it by token &nbsp;id: !token-mod --set imgsrc|+@{target|token_id}
1615177890
The Aaron
Roll20 Production Team
API Scripter
DougA said: I'm probably going about this all the wrong way - But basically I want to use TokenMod to do the settings to change Monster/NPC hit points scaled based on the maximum possible for them via npc_hpformula. Hung up on how to get the Maximum calculated - any attempt gets me a roll of the npc_hpformula attribute which is not what I'm after. I have used the setup monster tokens. I want to remove the work for me to adjust constantly my setups for party strengths because of different party sizes/levels on one shots and the need to just increase difficulty on my hard cover campaigns. Im setting up my macro to click on a token - read the npc_hpformula attribute - calc the max and apply a rounded hp from a queried percentage entered by me depending on the situation. There's not a way to do that directly with TokenMod. Probably that would require writing a custom script.&nbsp;
Thanks for the response Aaron - at least I know now to stop digging myself a hole where I'm at - I can do it manually which is doable, just another thing to do - I display the attribute npc_hpforumula in chat so I don't have to look it up then I just have to calculate it myself and then I have then next step query what I want the HP to be and have Token_mod update it. I looked at MonsterHitDice script and see that your accessing it I will try to use that as a base to parse out how many dice of what type and add the +bonus and do it that way - My coding is just really rusty - can read it - just can't create it off the cuff very well. I stopped coding when Pascal was on a set of 5.25" floppies!!.
1615256891

Edited 1615304492
The Aaron
Roll20 Production Team
API Scripter
If it helps, here's a little function that should give you the maximum from a dice expression: const expressionMax = (txt) =&gt; { const tokenize = /(\d+d\d+|\d+|\+|-)/ig; const dieparts = /^(\d+)?d(\d+)$/i; const ops = { '+': (m,n) =&gt; m+n, '-': (m,n) =&gt; m-n }; let op = '+'; return (txt.replace(/\s+/g,'').match(tokenize)||[]).reduce((m,t)=&gt;{ let matches = t.match(dieparts); if(matches){ return ops[op](m,[...Array(parseInt(matches[1])||1)].reduce(m=&gt;m+(parseInt(matches[2])),0)); } else if(/^\d+$/.test(t)){ return ops[op](m,parseInt(t)); } else { op = t; return m; } },0); }; Example: expressionMax("1d6 + 3+4d4-7"); 18
1615303882

Edited 1615310181
timmaugh
Pro
API Scripter
APILogic now exposes a way for scriptlets to register themselves as plugins... meaning: APILogic is already handling and manipulating the command lines of other scripts, so by letting a script register as a plugin you gain an immediate way to add any* data retrieval and/or parsing you require and plug it in to your command line. In other words, even if token-mod doesn't have the ability you are looking for, you can get it as a plugin for APIL and drop an EVAL tag into a token-mod. For instance, since Aaron's script, just above, already returns a value, it &nbsp; would only require a small addition to turn it into an APIL plugin: const expressionMaxPlugin = (m) =&gt; { &nbsp;&nbsp;&nbsp;&nbsp;return expressionMax(m.content.slice(m.content.indexOf(' '))); }; on('ready', () =&gt; { try { APILogic.RegisterRule(expressionMaxPlugin); } catch (error) { log(error); } }); Then, anywhere in your token-mod line where you needed to access that, you could drop an EVAL tag with the dice expression Aaron's script would expect: {&amp; eval expressionMaxPlugin(1d6 + 3+4d4-7) } ... and by the time token-mod gets the line, this will have been parsed down to 18. * - by 'any' we're talking synchronous code. Asynchronous won't work.
1615311373
timmaugh
Pro
API Scripter
Zachary B. said: I'm encountering a problem using @{selected}. If I highlight more than 1 token and attempt to execute my macro, it applies one token's information to all tokens. Is there a way to have a group selected and then have the tokenmod affect each token individually? Can the&nbsp; forselected &nbsp;handle of SelectManager help with that? Not sure if this output matches the intended behavior you're looking for, but if you prepended your tokenmod command line with&nbsp; forselected &nbsp;and then replaced all of your @{selected...} calls with at{selected...}, forselected would iterate over the selected group and retrieve their individual data.
1615315266
timmaugh
Pro
API Scripter
timmaugh said: Zachary B. said: I'm encountering a problem using @{selected}. If I highlight more than 1 token and attempt to execute my macro, it applies one token's information to all tokens. Is there a way to have a group selected and then have the tokenmod affect each token individually? Can the&nbsp; forselected &nbsp;handle of SelectManager help with that? Not sure if this output matches the intended behavior you're looking for, but if you prepended your tokenmod command line with&nbsp; forselected &nbsp;and then replaced all of your @{selected...} calls with at{selected...}, forselected would iterate over the selected group and retrieve their individual data. Yes, the above will work, at least for @{selected} items! Here is an example... usually this line would "cross the streams" and write the *first* selected character's name over the others if you had multiple selected: !token-mod --set name|"@{selected|character_name} likes tacos" But if you have SelectManager installed, you can change that slightly and use&nbsp; forselected : !forselected token-mod --set name|"at{selected|character_name} likes tacos" Here's the effect on a game where I had 3 tokens selected: Very cool. Other things that you might want to individualize across many tokens (like each token having their own inline roll, for instance): !forselected token-mod --set bar1|[[3d6]] Could probably be handled (in a couple of different ways) with APILogic (in fact, both SM and APIL could play together in the same token-mod call). I will run some tests and post back!
1615331694

Edited 1615338924
Can anyone give me some help debugging this simple script? Basically when our bard wants to use Bardic Inspiration, he will run this from the token action bar and it will put a statusmarker (I was hoping aura) on the target. !power {{&nbsp;&nbsp; &nbsp; &nbsp; --name|Bardic Inspiration &nbsp; --tokenid|@{selected|token_id} &nbsp; --target_list|@{target|token_id} &nbsp; --emote|@{selected|character_name} sings the words 'War Pig' to@{target|token_name}! &nbsp; --Effect:| You can inspire others through stirring words or music. To do so, you use a Bonus Action on Your Turn to choose one creature other than yourself within 60 feet of you who can hear you. That creature gains one Bardic Inspiration die: **A d8.**^^^^ Once within the next 10 minutes, the creature can roll the die and add the number rolled to one ability check, Attack roll, or saving throw it makes. The creature can wait until after it rolls The d20 before deciding to use the Bardic Inspiration die, but must decide before the DM says whether the roll succeeds or fails. ^^^^Once the Bardic Inspiration die is rolled, it is lost. A creature can have only one Bardic Inspiration die at a time. ^^^^You can use this feature a number of times equal to your Charisma modifier //**(Bard’s is 4)**//. You regain any expended uses when you finish a Long Rest. --api_token-mod|_ids @{selected|token_id}_set statusmarkers|!aura }} Thanks (By the way I know there is a giant wall of text in this card but that is what my players like.) Everything seems to work except the last line where the --api call is.
1615351289
timmaugh
Pro
API Scripter
If you want to set the aura, don't mess with the statusmarker. The following token-mod toggles an aura of 5 units, and sets the color to red: !token-mod --ids @{selected|token_id} --set aura1_radius|!5 aura1_color|ff2463 Now, to map it into your powercards macro, it looks like there is some substitution with underscores, but I'm not familiar enough with that to guide you on the syntax. Point is, though, you can set the aura directly.
1615352848

Edited 1638899081
timmaugh
Pro
API Scripter
timmaugh said: Other things that you might want to individualize across many tokens (like each token having their own inline roll, for instance): !forselected token-mod --set bar1|[[3d6]] Could probably be handled (in a couple of different ways) with APILogic (in fact, both SM and APIL could play together in the same token-mod call). I will run some tests and post back! I'm back with a report on this, and happy to say that it worked just as imagined! Currently there is only one trick to making it work, and that is having SelectManager installed before APILogic. (Both scripts shin-kick their way to the front of other messages, but it matters how these two interact with each other.) The whole idea is that we defer the roll until the command runs for each individual token. Here are three syntax implementations that work: 1) A Variable Stored in a Mule The character Heretic has a Mule Ability named "MyMule" that has a variable "tmtest" with a value of "[[3d6]]". In the following command, we load the Mule and retrieve the variable: !forselected token-mod --set bar1|get.tmtest {&amp; mule Heretic.MyMule} With 4 tokens selected, you can see that their bar1 values were all individually set. 2) Mule with Deferred Inline Roll In a very similar application, the following loads a Mule but doesn't retrieve the variable. Instead, it defers the inline roll by use of slash marks. These will be removed (and the roll will be detected) after the first cycle through the message by APILogic, but by then, SelectManager will have handed off the proper selected token: !forselected token-mod --set bar1|[\[3d6]\] {&amp; mule Heretic.MyMule} 3) Eval and Deferred Inline Roll This time, we use an EVAL tag to run a non-existent plugin "null". That is enough to trigger APILogic's parsing, which then eventually catches the inline roll. But again, by that point SelectManager has already handed off the next selected token. !forselected token-mod --set bar1|[\[3d6]\] {&amp; eval} null() {&amp; /eval} 4) Math and Deferred Inline Roll Maybe we don't know how many dice to roll, but we can arrive at the number through an equation. Or we know how many, and we express it as an equation. Since the MATH tag is enough to trigger APILogic parsing, it works. Again, we use a deferred inline roll: !forselected token-mod --set bar1|[\[{&amp;math 1+2}d6]\] All of the above (and others) work, and they demonstrate how the 3 scripts can work together on a single message!
1615381799
The Aaron
Roll20 Production Team
API Scripter
Chris M. said: Can anyone give me some help debugging this simple script? Basically when our bard wants to use Bardic Inspiration, he will run this from the token action bar and it will put a statusmarker (I was hoping aura) on the target. !power {{&nbsp;&nbsp; &nbsp; &nbsp; --name|Bardic Inspiration &nbsp; --tokenid|@{selected|token_id} &nbsp; --target_list|@{target|token_id} &nbsp; --emote|@{selected|character_name} sings the words 'War Pig' to@{target|token_name}! &nbsp; --Effect:| You can inspire others through stirring words or music. To do so, you use a Bonus Action on Your Turn to choose one creature other than yourself within 60 feet of you who can hear you. That creature gains one Bardic Inspiration die: **A d8.**^^^^ Once within the next 10 minutes, the creature can roll the die and add the number rolled to one ability check, Attack roll, or saving throw it makes. The creature can wait until after it rolls The d20 before deciding to use the Bardic Inspiration die, but must decide before the DM says whether the roll succeeds or fails. ^^^^Once the Bardic Inspiration die is rolled, it is lost. A creature can have only one Bardic Inspiration die at a time. ^^^^You can use this feature a number of times equal to your Charisma modifier //**(Bard’s is 4)**//. You regain any expended uses when you finish a Long Rest. --api_token-mod|_ids @{selected|token_id}_set statusmarkers|!aura }} Thanks (By the way I know there is a giant wall of text in this card but that is what my players like.) Everything seems to work except the last line where the --api call is. Generally, I'd suggest about this in the PowerCards thread.&nbsp; That said, I'm guessing you need a space between @{selected|token_id} and _set: --api_token-mod|_ids @{selected|token_id} _set statusmarkers|!aura