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

Show Buttons API Script error with non-controlled players

1710976383

Edited 1710976396
@timmaugh I do love this API! However, in a game I'm managing, I've been using with an @{target|character_name} command. I notice the Script will crash if I use it on a token  NOT controlled the activating player (which I totally understand), as seen bellow: TypeError: Cannot read properties of undefined (reading 'id') TypeError: Cannot read properties of undefined (reading 'id') at apiscript.js:28316:98 at Array.forEach (<anonymous>) at apiscript.js:28314:23 at Array.forEach (<anonymous>) at handleInput (apiscript.js:28313:29) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1762:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) Is there a way to bypass  or allow players to add abilities to a sheet they don't control; in the same manner as say, token-mod or chattsetattr APIs? (I'm using it to show a token-action button on other PCs or NPCs for something like Bardic Inspiration - using it hides it appropriately. It works fine if  a GM runs it, but a player targeting a non-controlled token breaks it) (Not a big deal if it can't) Thanks everyone for their time, help & input!
1710980181
timmaugh
Pro
API Scripter
Hey, Jukite... sorry about that. I can add that ability in -- probably as a configurable option that you can turn on/off (in case someone doesn't want it enabled). Also, if it's disabled, you shouldn't get an error, so I can probably patch that, too. Can you do me a favor and install ScriptInfo in your game, then run this command: !scriptinfo 28316 That should give you a particular line number in ShowButtons that it correlates to. I just want to make sure that in what I'm seeing (and fixing), I'm catching the thing that is causing your error. Thanks!
Thank you for the speedy response! I installed & ran the scriptinfo command (in normal sandbox) with the following output: Script Information (Line 28316) Line 28316 corresponds to line 299 in ShowButtons.
1710981426
timmaugh
Pro
API Scripter
OK, thanks! I'll post back with an update asap!
1710981667

Edited 1710981711
No worries & no rush (at least for me, it's a bi-weekly game so I don't need to patch it for another week) But I appreciate you doing it! Thank you!
1712004719
timmaugh
Pro
API Scripter
OK, I put the update into ShowButtons and released the new version (v1.0.1). It is being added to the one-click (provided the Roll20 person who does the merging remembers to perform all the required steps). In the meantime, you can also get it from my repo . This version lets you configure a new option in the script: playerscanids Turning this on will allow players to target characters they do not control, much like what Jukite describes, above. To turn this feature "on", you would run: !showbuttonsconfig +playerscanids For those interested, here is the original thread with the purpose and functionality of  ShowButtons.
Thank you SO much Timmaugh for getting this completed! I appreciate it! (One day I'll have the bravery to start using your meta-scripts toolbox....I've looked at it, but it looks so daunting because it can do a lot!)