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

Unhandled Exception in SpawnDefaultToken

1609428985
Nick O.
Forum Champion
I'm trying to have a necromancer summon up a handful of skeletons from the Monster Manual via the SpawnDefaultToken script. I have copied the skeleton's artwork to my library, I have the necromancer's token selected, and am using the following command !Spawn{{ --name|Skeleton --qty|6 --placement|surround }} When this runs, I get "(From SpawnAPI): Unhandled exception: undefined" in the chat log, and "ERROR: You must specify a valid layer to create this object type." appears in the API Output Console. I have been able to use the script to successfully summon PCs' tokens to the board, this only seems to happen when trying to call monsters. Has anyone encountered this before? 
1609431625
The Aaron
Roll20 Production Team
API Scripter
Reading through that script, I feel like this could never have worked. =D If you add this on line 260, it should make it work: //////////////////////////////////////////////////////////// // Spawn the Token! //////////////////////////////////////////////////////////// /* 260 */ baseObj.layer = baseObj.layer||'objects'; spawnObj = createObj('graphic',baseObj); Really, it should get the layer from the selected tokens and pass it in so that if you use it on a GM layer token, it will spawn on the GM layer, but this should work for most cases until David M. can propagate the real layer through all the code. Probably the reason it has been working is that sometimes the layer is stored with the defaulttoken, but in your case, it isn't.
1609441452
David M.
Pro
API Scripter
Thanks for bringing this to my attention, guys. Never ran across that issue before. My condolences to Aaron for witnessing the atrocity that is the source code of that script (my 2nd js project ever). It started as such a simple idea, then I kept adding more gadgets. Original Concept&nbsp; &nbsp; ----------&nbsp; &nbsp;Final product &nbsp; Anyway, here's the updated Gist. Assuming no horrible unintended consequences, I'll put in a pull request for next week's update. <a href="https://github.com/djmoorehead/roll20-api-scripts/blob/master/Spawn%20Default%20Token/SpawnDefaultToken.js" rel="nofollow">https://github.com/djmoorehead/roll20-api-scripts/blob/master/Spawn%20Default%20Token/SpawnDefaultToken.js</a> Primary changes were to the current lines 1040 (gets layer of origin token) and 153 (assigns the layer property of spawned token to that of the origin token).
1609443281
The Aaron
Roll20 Production Team
API Scripter
No worries, we don't start painting like Leonardo...&nbsp; you should look at some of my early scripts... on second thought, you should NOT look at them. =D&nbsp;&nbsp;
1609511242

Edited 1609511270
Nick O.
Forum Champion
Thanks for turning the fix around so quickly, David! It works great! And don't worry about it, what you've built is way more sophisticated than anything I've ever done.
1609511754
Nick O.
Forum Champion
Also, do you all know if something behind the scenes in the API changed? I was able to summon a couple of monsters whose artwork wasn't in my local library.&nbsp;
1609521684

Edited 1609521964
What are the url's to that artwork? Lately I've seen some marketplate items that do not have the marketplace related URLs, but user related ones.&nbsp; For example Elvenforest from 2D Storytelling artwork urls start with&nbsp; <a href="https://s3.amazonaws.com/files.d20.io/images/150858" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/150858</a> etecera . Whereas the marketplace urls start with&nbsp;<a href="https://s3.amazonaws.com/files.d20.io/marketplace/547" rel="nofollow">https://s3.amazonaws.com/files.d20.io/marketplace/547</a> etcetera.&nbsp;
1609523236
The Aaron
Roll20 Production Team
API Scripter
Nick, Martijn, any other examples?&nbsp; Is it always Addons that have the issue?
1609525610
Nick O.
Forum Champion
For monsters, tokens that are coming from the 5e Monster Manual, Mordenkainen's Tome of Foes and the Creature Codex from Kobold Press all have this prefix <a href="https://s3.amazonaws.com/files.d20.io/images/" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/</a> [number] For objects, like the weapons included in Weapons of Magic from Norse Foundry, have marketplace in their path. <a href="https://s3.amazonaws.com/files.d20.io/marketplace/[number]" rel="nofollow">https://s3.amazonaws.com/files.d20.io/marketplace/[number]</a>
1609525911
The Aaron
Roll20 Production Team
API Scripter
That's great info, thanks Nick!
1609536801
Nick O.
Forum Champion
It's definitely cool, I'm just not sure if it's supposed to be like this. I couldn't summon certain monsters from those sources yesterday, and now I can.