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 to show what tokens pass a passive perception check

1621875401

Edited 1621875600
Hey all, ran my 1st game last weekend on Roll20 and there is a LOT of things I need to pick up on LOL.  One question I have. Is there a way to query all the tokens on a page and show which ones have a passive_wisdom stat higher than a set amount?  Here is what I am trying to do.  I have a script to regenerate hp on characters /w gm &{template:default} {{desc=**Regeneration** Healed for [[{?{Healed HP|10},@{selected|bar1|max}-@{selected|bar1}}dh1]] Perception DC=[[ceil(20-20*{?{Healed HP|10},@{selected|bar1|max}-@{selected|bar1}}dh1/@{selected|bar1|max})]] }} !token-mod --set bar1_value|+[[{?{Healed HP|10},@{selected|bar1|max}-@{selected|bar1}}dh1]] Part of what it does is calculate how difficult it would be for a PC to passively notice the enemy is healing. What I would like to then list all the tokens on the page that have a Passive Perception of 18 or higher.  Is there a script that could do this?  Something like: !find-char --<attribute>|<value> Called like this in my example !find-char --passive_wisdom|>=18
1621876720
timmaugh
Pro
API Scripter
If no one can suggest another script that satisfies this need, I do have one in the works as a part of the meta toolbox so that you could filter by logical combinations of things like this, either to simply report the information you return or to feed those tokens to another meta-script (maybe to virtually select them) or to a standard script (as IDs to take action on). Should be a few days before it's ready, however.
1621877705

Edited 1621878423
David M.
Pro
API Scripter
Here is a scriptcard that could work for you (using 5e OGL attributes). Based on this scriptcard solution , I only added two lines and modified one other (bold lines below). It reports the [unsorted] passive perception of every token on the page on the GM and Object layers that are greater than or equal to a user-specific value.  EDIT - I added a subtitle to the output to display the target DC. You can also alter to whisper the output to the GM by adding a  --#whisper|gm line anywhere in there. EDIT 2 - I forgot to mention you have to select a token first in order to determine the page in which to look. !script {{ --#title|Global Passive Perception --=DC|?{Passive Perception DC?|10} --#leftsub|Target DC[$DC] --:(1) GET ALL TOKENS INTO THE "allTokens" ARRAY| will have blank 1st element to be removed later --~|array;pagetokens;allTokens;@{selected|token_id} --:(2) PREP ARRAY FOR LOOP| if no array elements then end macro --~tokenid|array;getfirst;allTokens --?[&tokenid] -eq ArrayError|End --:(3) GRAB PASSIVE PERCEPTION FROM EACH TOKEN| --:PPLoop| --:TOKEN MUST BE ON OBJECTS OR GMLAYER AND HAVE A NON_BLANK PASSIVE_WISDOM| --?[*[&tokenid]:t-layer] -ne objects -and [*[&tokenid]:t-layer] -ne gmlayer|NextToken --?[*[&tokenid]:passive_wisdom] -ne "" -and [*[&tokenid]:passive_wisdom] -ge [$DC]|>DisplayPP --:NextToken| --~tokenid|array;getnext;allTokens --?[&tokenid] -ne ArrayError|PPLoop --:End| --X| --:DisplayPP| --=PP|[*[&tokenid]:passive_wisdom] ​--+[*[&tokenid]:character_name]|[$PP] --<| }} Example output: Added whisper below and reduced DC to 11:
Thanks David. I will try it out. I did think about using your Radar script as well :)  But I didn't need the locations, just the people David M. said: Here is a scriptcard that could work for you (using 5e OGL attributes). Based on this scriptcard solution , I only added two lines and modified one other (bold lines below). It reports the [unsorted] passive perception of every token on the page on the GM and Object layers that are greater than or equal to a user-specific value.  EDIT - I added a subtitle to the output to display the target DC. You can also alter to whisper the output to the GM by adding a  --#whisper|gm line anywhere in there. EDIT 2 - I forgot to mention you have to select a token first in order to determine the page in which to look. !script {{ --#title|Global Passive Perception --=DC|?{Passive Perception DC?|10} --#leftsub|Target DC[$DC] --:(1) GET ALL TOKENS INTO THE "allTokens" ARRAY| will have blank 1st element to be removed later --~|array;pagetokens;allTokens;@{selected|token_id} --:(2) PREP ARRAY FOR LOOP| if no array elements then end macro --~tokenid|array;getfirst;allTokens --?[&tokenid] -eq ArrayError|End --:(3) GRAB PASSIVE PERCEPTION FROM EACH TOKEN| --:PPLoop| --:TOKEN MUST BE ON OBJECTS OR GMLAYER AND HAVE A NON_BLANK PASSIVE_WISDOM| --?[*[&tokenid]:t-layer] -ne objects -and [*[&tokenid]:t-layer] -ne gmlayer|NextToken --?[*[&tokenid]:passive_wisdom] -ne "" -and [*[&tokenid]:passive_wisdom] -ge [$DC]|>DisplayPP --:NextToken| --~tokenid|array;getnext;allTokens --?[&tokenid] -ne ArrayError|PPLoop --:End| --X| --:DisplayPP| --=PP|[*[&tokenid]:passive_wisdom] ​--+[*[&tokenid]:character_name]|[$PP] --<| }} Example output: Added whisper below and reduced DC to 11: