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

My Character sheet/Wizard token is shutting down my API sandbox

I am having trouble with one of my players character sheet/token. I am using the D&amp;D 5E by Roll20 character sheet along with the 5th Edition OGL by Roll20 Companion.&nbsp; I created a SFX spellbook for one my players Wizard PC.&nbsp; For this spell book I created a "Cloud of Daggers Spell sfx" using an API from a you tube video created by Nick Olivo.&nbsp; When I use the macro containing my "Cloud of Daggers API" with the Wizard character sheet/token the script and API, the API sandbox shuts down.&nbsp; When I use the macro containing my "Cloud of Daggers API" with other character sheets/tokens the script and API work just fine and the API sandbox does not shut down.&nbsp; I have run out ideas with my problem solving.&nbsp; Any Help would be appreciated. This is the API script I am using: on("ready",function() { &nbsp;&nbsp;&nbsp; on("chat:message",function(msg){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(msg.type=="api" &amp;&amp;msg.content.indexOf("!cloudofdaggers")==0) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var selected = msg.selected; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (selected===undefined) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat("API", "Please select a character."); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var tok = getObj("graphic",selected[0]._id); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var character = getObj("character",tok.get("represents")); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var player = getObj("player",character.get("controlledby")); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; createObj("graphic",{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left:tok.get("left")+70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; top:tok.get("top"), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width:70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pageid:tok.get("pageid"), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layer:"objects", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imgsrc:"<a href="https://s3.amazonaws.com/files.d20.io/images/335183605/aLBEcpRKn6mRQctaIrh69w/thumb.png?16802918135" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/335183605/aLBEcpRKn6mRQctaIrh69w/thumb.png?16802918135</a>", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name:tok.get("name") + "'s Cloud of Daggers", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controlledby:player.get("id"), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aura1_square:true, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aura1_radius:0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aura1_color:"#ff00ff", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; showplayers_aura1:true, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat(tok.get("name"),"summoned a cloud of daggers."); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnFx(tok.get("left")+70,tok.get("top"),"bomb-magic",tok.get("pageid")); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; }); }); This is the macro I use that calls the API Script: !cloudofdaggers &amp;{template:npcaction} {{name=@{selected|character_name} ***Cloud of Daggers***}} {{description=**Spell Cast as Level ?{Level?|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}** **Duration: Concentration Up to 1 minute** *You fill the air with spinning daggers in a cube 5 feet on each side, centered on a point you choose within range. A creature takes 4d4 slashing damage when it enters the spell’s area for the first time on a turn or starts its turn there.* **At Higher Levels:** *When you cast this spell using a spell slot of 3rd level or higher, the damage increases by 2d4 for each slot level above 2nd.*}} !modbattr --charid @{selected|character_id} --silent --lvl?{Level?}_slots_expended|-1!!! When ever I use the macro that includes this API script using the Wizard Character the sandbox shuts down and I get the following error: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again. More info... If this script was installed from the Mod Library, you might find help in the Community API Forum. For reference, the error message generated was: TypeError: Cannot read properties of undefined (reading 'get') TypeError: Cannot read properties of undefined (reading 'get') &nbsp;&nbsp;&nbsp; at apiscript.js:30255:37 &nbsp;&nbsp;&nbsp; at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:65:16) &nbsp;&nbsp;&nbsp; at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:70:8) &nbsp;&nbsp;&nbsp; at /home/node/d20-api-server/api.js:1762:12 &nbsp;&nbsp;&nbsp; at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 &nbsp;&nbsp;&nbsp; at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) &nbsp;&nbsp;&nbsp; at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) &nbsp;&nbsp;&nbsp; at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) &nbsp;&nbsp;&nbsp; at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) &nbsp;&nbsp;&nbsp; at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400
1680370494

Edited 1680370689
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Just a quick check. Select the token in question. Can you verify that the token, as it sits on the VTT both represents the character and that the character has one specific controller? You can also try messaging Nick Olivo directly. He's a nice and helpful guy!
So I deleted the Wizard token off the battlemap and dragged a new token from the Journal back on to the battlemap.&nbsp; I opened up the edit window and the character was controlled by 2 players . &nbsp; I deleted one of the players, hit save and tried my SFX spellbook again. Everything worked just fine!&nbsp; Sometimes you develop tunnel vision on a problem and a friendly, "hey, did you check this" helps so much.&nbsp; Thanks for helping me take off the blinders Keith!
1680376369
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It was a hunch based on the "get" operation failing. There were only two&nbsp; .get &nbsp;instances in the script and that one looked like the most likely issue.