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

Need help with token conversion macro

I'm trying to create a single macro to merge to separate macros I use for converting PC and NPC tokens. Both macros work on their own but the NPC macro doesn't work within the query structure. ?{Token Type |PC,!token-mod {{ --set bar1_link# bar2_link# bar3_link# bar1# bar2# bar3# }} !token-mod {{ --set bar1_link#hp --set bar2_link#speed --set bar3_link#passive_wisdom --set name#@{selected|character_name} --on showname --on showplayers_name --on showplayers_bar1 --on showplayers_bar2 --on showplayers_bar3 --on showplayers_aura1 --on showplayers_aura2 --on light_hassight --on has_bright_light_vision --set bar_location#overlap_top --set defaulttoken }} |NPC,!token-mod {{ --set bar1_link# bar2_link# bar3_link# bar1# bar2# bar3# }} !token-mod {{ --set bar1_max#@{selected|hp|max} --set bar1_value#@{selected|hp|max} --set bar2_value#@{selected|npc_speed} --set bar3_value#[[[[@{selected|npcd_wis_mod}*{1@{selected|npc_perception}0,0}=10+0@{selected|npc_perception}]]+10]] --on showname --on showplayers_bar1 --off showplayers_bar2 --off showplayers_bar3 --off showplayers_name --on showplayers_aura1 --on showplayers_aura2 --off light_hassight --off has_bright_light_vision --set bar_location#overlap_top --set defaulttoken}}}&{noerror}
1631826550
GiGs
Pro
Sheet Author
API Scripter
My guess is its this line: --set bar3_value#[[[[@{selected|npcd_wis_mod}*{1@{selected|npc_perception}0,0}=10+0@{selected|npc_perception}]]+10]] specifically this part: {1@{selected|npc_perception}0,0} I'm not familiar with that syntax, but the issue is probably the } at the very end and the comma before it - those need to be replaced by html entities to work in the query.
It blows up on these three lines: --set bar1_max#@{selected|hp|max} --set bar1_value#@{selected|hp|max} --set bar3_value#[[[[@{selected|npcd_wis_mod}*{1@{selected|npc_perception}0,0}=10+0@{selected|npc_perception}]]+10]] I've tried replacing }s and |s with HTML codes in various places with no luck. It's the second | in the first two lines and I really don't know what in the third line. The ending } and first | in @{selected functions seem to be fine.
1631836235

Edited 1631842980
GiGs
Pro
Sheet Author
API Scripter
I wonder if token mod has a different way to access the max of an attribute. I dont know why its failing there. You never use html replacements on attribute calls like @{selected|hp|max} or @{selected|npc_perception} - trying to do so will break the attribute call. The third line will be the comma and the } I mentioned earlier. The query interprets them as part of the query structure, so it breaks. For testing purposes, replace that comma and } with html enties, and replace the first two lines with non-max calls like @{selected|hp} just to see if it works. If it works, we can concentrate on figuring out why hp_max is failing. Also, just to check: you do have a value inhp_max? It's not created unless you or the character sheet creates it.
NPC sheets tend to have no current or max set to begin with.  Unless owning the Monster Manual changes this somewhere?
1631855573
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
What is npcd_wis_mod? {1@{selected|npc_perception}0,0} is unfamiliar syntax. A compendium dropped NPC will have an hp|max. It's the default input for bar 1 on a fresh game with no customizations.
{#,#} is grouping to ensure a numeric value is returned in case a variable is empty. npcd_wis_mod is the NPC's wisdom modifier on some character sheets. The NPC sheets have a max hp value but no current hp value. I tried removing the 2 hp|max lines and replacing , and/or } on the 3rd line with no success. All these commands work when not in a query structure.
I found a partial solution by changing from the !token-mod {{ parameters }} format to the !token-mod parameters format but the problem is the macro ignores everything after so you can't have another pulldown option or other commands after the one using the different format. For example: !token-mod {{ --set bar1_link# bar2_link# bar3_link# bar1# bar2# bar3# bar_location#overlap_top --on showplayers_bar1 showplayers_aura1 showplayers_aura2 showname }} ?{Token Type |PC,!token-mod {{ --set bar1_link#hp --set bar2_link#speed --set bar3_link#passive_wisdom --set name#@{selected|character_name} --on showplayers_name --on showplayers_bar2 --on showplayers_bar3 --on has_bright_light_vision }} |NPC,!token-mod --set bar1_max#@{selected|hp|max} bar1_value#@{selected|hp|max} bar2_value#@{selected|npc_speed} bar3_value#[[[[@{selected|npcd_wis_mod}*{1@{selected|npc_perception}0,0}=10+0@{selected|npc_perception}]]+10]] --off showplayers_bar2 showplayers_bar3 showplayers_name has_bright_light_vision anything else }&{noerror} Everything works up to the "anything else"  line, nothing there or after works.
Assuming you're using the D&D 5E by Roll20 sheet, I'm pretty sure the issue is the deprecated attribute call here: @{selected|npcd_wis_mod}. I just pulled in a new monster and the npcd attributes aren't even listed anymore.  They may still be there, or just hidden on the Attributes & Abilities page, but it appears that they have been removed from the sheet entirely.  As an FYI, my understanding is that the 'd' portion of those attributes referred to the 'display' value when the sheet was open and being edited, as those values would be edited and then the sheetworkers would adjust the related attributes (such as npc_wis_mod) when the field was closed.  I'm guessing that you simply want an NPC's passive perception to be displayed in Bar 3?  If that's the case, it looks like the sheet has been updated to use the 'passive_wisdom' for both PCs and NPCs now. I just tested it on a current PC and NPC and it looks like it automatically updates for changes to both. You also had two separate !token-mod calls in the NPC result for some reason. So this adjustment is working for me: ?{Token Type|PC,!token-mod {{ --set bar1_link# bar2_link# bar3_link# bar1# bar2# bar3# }} !token-mod {{ --set bar1_link#hp --set bar2_link#speed --set bar3_link#passive_wisdom --set name#@{selected|character_name} --on showname --on showplayers_name --on showplayers_bar1 --on showplayers_bar2 --on showplayers_bar3 --on showplayers_aura1 --on showplayers_aura2 --on light_hassight --on has_bright_light_vision --set bar_location#overlap_top --set defaulttoken }} |NPC,!token-mod {{ --set bar1_link# bar2_link# bar3_link# bar1# bar2# bar3# }} !token-mod {{ --set bar1_max#@{selected|hp|max} --set bar1_value#@{selected|hp|max} --set bar2_value#@{selected|npc_speed} --set bar3_value#@{selected|passive_wisdom} --on showname --on showplayers_bar1 --off showplayers_bar2 --off showplayers_bar3 --off showplayers_name --on showplayers_aura1 --on showplayers_aura2 --off light_hassight --off has_bright_light_vision --set bar_location#overlap_top --set defaulttoken}}}&{noerror}