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 .
×

API that scans the passives of only players on map and also has a notice for traps dc to let you know who made or failed check.

Title says it all. The API on !passives scans and reports only the current players on map passives like this.  The problem is it returns all 0's for the scores. With changes from 2014 to 2024 and weekly updates as well I have no idea how to get the correct numbers. Here is the script: on('chat:message', function(msg) { if (msg.type !== 'api') return; // Helper: get all player tokens on the current map function getPlayerTokens(pageId){ return findObjs({ _type: 'graphic', _pageid: pageId, _subtype: 'token', layer: 'objects' }).filter(t => t.get('represents') && getObj('character', t.get('represents')).get('controlledby')); } // Gather party info from tokens function getPartyFromTokens(pageId){ let tokens = getPlayerTokens(pageId); let list = []; tokens.forEach(token => { let char = getObj('character', token.get('represents')); if(!char) return; let pp = parseInt(getAttrByName(char.id,'passive_perception')) || 0; let pi = parseInt(getAttrByName(char.id,'passive_investigation')) || 0; let ins = parseInt(getAttrByName(char.id,'passive_insight')) || 0; list.push({ name: char.get('name'), pp: pp, pi: pi, ins: ins }); }); // sort by PP highest → lowest list.sort((a,b) => b.pp - a.pp); return list; } // --- COMMAND: !passives --- if(msg.content === '!passives'){ let pageId = Campaign().get('playerpageid'); let list = getPartyFromTokens(pageId); if(list.length === 0){ sendChat("GM Radar","/w gm No player tokens found on this page."); return; } let output = "&{template:default} {{name=Passive Sense Radar}}"; list.forEach((entry, idx) => { let line = `PP ${entry.pp} | PI ${entry.pi} | INS ${entry.ins}`; if(idx === 0) line = "👁️ " + line + " (Highest)"; output += `{{${entry.name}=${line}}}`; }); sendChat("GM Radar","/w gm "+output); } // --- COMMAND: !noticedc X --- if(msg.content.startsWith('!noticedc')){ let parts = msg.content.split(' '); let dc = parseInt(parts[1]); if(!dc){ sendChat("GM Radar","/w gm Usage: !noticedc 15"); return; } let pageId = Campaign().get('playerpageid'); let list = getPartyFromTokens(pageId); if(list.length === 0){ sendChat("GM Radar","/w gm No player tokens found on this page."); return; } let output = `&{template:default} {{name=Passive Perception vs DC ${dc}}}`; list.forEach(entry => { let result = entry.pp >= dc ? "✔ Notices" : "✖ Misses"; output += `{{${entry.name}=PP ${entry.pp} → ${result}}}`; }); sendChat("GM Radar","/w gm "+output); } }); The second part is used with Send to Chat reaction to see if anyone made dc to detect trap. !noticedc # Any help would be great as I had to get AI to help me with this. Still learning and have more ideas than knowhow.
1773267733
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Cron! Get and Set will not work with the 2024 sheet as the Beacon architecture is asynchrornous. It's a total pain to work with, and probably the most difficult hurdle in getting scripts to work directly with that sheet. You want to you getSheetItem and setSheetItem. You can find documentation here . If you are using AI-assisted scripting, you might want to just send the contents of that page to your agent.
1773270596

Edited 1773270915
Cron
Pro
Hello! Thanks keithcurtis. I did as you suggest yet the AI was still not able to get it to work. I guess I will scrap the idea for a few dozen updates later in hopes they add more features. I have a macro that will pull passives, just do not understand why API does not have the same access. I will do as Gauss suggested on discord and try to get it to work as a macro in Send to Chat reaction. I really just need the instigator name vs everyone. The way some people charge ahead without looking first in my games it will tend to be the same persons over and over lol. Thanks for the help. I do not mind banging my head into the wall till I can get things to work, just nice now and then to know when to stop, or at least wait for updates.