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

Shapeshift Script all of the sudden causing an error

I have used this script for a few years now without any issues and now whenever I try to create a new "Druid Token", I get this error Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'substring' of undefined TypeError: Cannot read property 'substring' of undefined at TrackedObj._validateAttrs (/home/node/d20-api-server/api.js:882:26) at TrackedObj.set (/home/node/d20-api-server/api.js:972:18) at apiscript.js:43579:43 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:186:9) at CharacterGet (apiscript.js:43578:19) at apiscript.js:43344:13 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1638:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 I don't get the error if I transmogrify an old Druid Token from a pre existing game. Did something in the Sheet change?
/**************************************** Druid Shift **************************************** This is for the 5E OGL sheet in Roll20. It will probably not work with any others without some modification. Also, I didn't do much in the way of error checking. The GM must make character named Druid X, where X is the creature being shifted into. It is suggested that the GM duplicate existing creatures, rename them, and assign to the druid player. The images for the characters must be uploaded and assigned to the avatar of the druid form characters. The easiest way I've found it to open the character sheet, edit, right click the picture in the avatar, copy, paste into your image program, save, upload and put it back in. Maybe you could just upload it back into the avatar directly. Anyways, this won't work if you don't first upload the image to your library. Either the druid player should have a general macro, or the forms characters should each have a token action with the body !DSBaseChar It's helpful if the druid character has token actions for each desired form. If you use multiple druids, or shapeshifters, add another check for !DSCharName for them. I put in several example forms in the code. Delete or add as needed. In the !DSBaseChar part of the code, you must replace 'Druid Char Name' with '<the druid character's name, exactly>'. *********************************************************************************************/ on("ready", function() { var getCleanImgsrc = function (imgsrc) { var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|original|max)([^\?]*)(\?[^?]+)?$/); if(parts) { return parts[1]+'thumb'+parts[3]+(parts[4]?parts[4]:`?${Math.round(Math.random()*9999999)}`); } return; }; on("chat:message", function (msg) { // Make sure to copy your druid character's name exactly in CharacterGet parameter. if (msg.type === "api" && msg.content === "!DSBaseChar") { CharacterGet('Lightbringer Doomstar', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSBaseChar2") { CharacterGet('Harbek Liadon', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSApe") { CharacterGet('Druid Ape', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSAxeBeak") { CharacterGet('Druid Axe Beak', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSBrownBear") { CharacterGet('Druid Brown Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSBlackBear") { CharacterGet('Druid Black Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCrocodile") { CharacterGet('Druid Crocodile', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSDireWolf") { CharacterGet('Druid Dire Wolf', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantBadger") { CharacterGet('Druid Giant Badger', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantCentipede") { CharacterGet('Druid Giant Centipede', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantEagle") { CharacterGet('Druid Giant Eagle', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantGoat") { CharacterGet('Druid Giant Goat', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantHyena") { CharacterGet('Druid Giant Hyena', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantOctopus") { CharacterGet('Druid Giant Octopus', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantSeaHorse") { CharacterGet('Druid Giant Sea Horse', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantSpider") { CharacterGet('Druid Giant Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantWolfSpider") { CharacterGet('Druid Giant Wolf Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantPoisonousSnake") { CharacterGet('Druid Giant Poisonous Snake', msg, 'Normal', 0); } if (msg.type === "api" && msg.content === "!DSGiantToad") { CharacterGet('Druid Giant Toad', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSPanther") { CharacterGet('Druid Panther', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSReefShark") { CharacterGet('Druid Reef Shark', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSWarhorse") { CharacterGet('Druid Warhorse', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSGiantVulture") { CharacterGet('Druid Giant Vulture', msg, 'Large', 30); } if (msg.type === "api" && msg.content === "!DSTiger") { CharacterGet('Druid Tiger', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSLion") { CharacterGet('Druid Lion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantAnt") { CharacterGet('Druid Giant Ant', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCaveBear") { CharacterGet('Druid Cave Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantBoar") { CharacterGet('Druid Giant Boar', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantConstrictorSnake") { CharacterGet('Druid Giant Constrictor Snake', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSConstrictorSnake") { CharacterGet('Druid Constrictor Snake', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantWasp") { CharacterGet('Druid Giant Wasp', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSHunterShark") { CharacterGet('Druid Hunter Shark', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSPlesiosaurus") { CharacterGet('Druid Plesiosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSPolarBear") { CharacterGet('Druid Polar Bear', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSQuetzalcoatlus") { CharacterGet('Druid Quetzalcoatlus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSRhinoceros") { CharacterGet('Druid Rhinoceros', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSSaberToothedTiger") { CharacterGet('Druid Saber-Toothed Tiger', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSAmphiptere") { CharacterGet('Druid Amphiptere', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSAnkylosaurus") { CharacterGet('Druid Ankylosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSMbielu") { CharacterGet('Druid Mbielu', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGiantScorpion") { CharacterGet('Druid Giant Scorpion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSKillerWhale") { CharacterGet('Druid Killer Whale', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSNightScorpion") { CharacterGet('Druid Night Scorpion', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSStygianFatTailedScorpion") { CharacterGet('Druid Stygian Fat-Tailed Scorpion', msg, 'Normal', 60); } if (msg.type === "api" && msg.content === "!DSJbaFofiSpider") { CharacterGet('Druid Jba Fofi Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantAntQueen") { CharacterGet('Druid Giant Ant Queen', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSCarrionBeetle") { CharacterGet('Druid Carrion Beetle', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSElephant") { CharacterGet('Druid Elephant', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSerpopard") { CharacterGet('Druid Serpopard', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSStegosaurus") { CharacterGet('Druid Stegosaurus', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSBrontosaurus") { CharacterGet('Druid Brontosaurus', msg, 'Gargantuan', 60); } if (msg.type === "api" && msg.content === "!DSNgobou") { CharacterGet('Druid Ngobou', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSDrakon") { CharacterGet('Druid Drakon', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantCrocodile") { CharacterGet('Druid Giant Crocodile', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGiantShark") { CharacterGet('Druid Giant Shark', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSKongamato") { CharacterGet('Druid Kongamato', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSTriceratops") { CharacterGet('Druid Triceratops', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSGbahali") { CharacterGet('Druid Gbahali', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSMammoth") { CharacterGet('Druid Mammoth', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSandSpider") { CharacterGet('Druid Sand Spider', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSGiantApe") { CharacterGet('Druid Giant Ape', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSTriceratops") { CharacterGet('Druid Triceratops', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSSavager") { CharacterGet('Druid Savager', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSTyrannosaurusRex") { CharacterGet('Druid Tyrannosaurus Rex', msg, 'Huge', 60); } if (msg.type === "api" && msg.content === "!DSEarthElemental") { CharacterGet('Druid Earth Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSFireElemental") { CharacterGet('Druid Fire Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSWaterElemental") { CharacterGet('Druid Water Elemental', msg, 'Large', 60); } if (msg.type === "api" && msg.content === "!DSAirElemental") { CharacterGet('Druid Air Elemental', msg, 'Large', 60); } }); function Size(charSize, msg) { if (charSize === "Normal"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 70); getObj(o._type,o._id).set("width", 70); });} if (charSize === "Large"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 140); getObj(o._type,o._id).set("width", 140); });} if (charSize === "Huge"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 210); getObj(o._type,o._id).set("width", 210); });} if (charSize === "Gargantuan"){ _.each(msg.selected,function (o) { getObj(o._type,o._id).set("height", 280); getObj(o._type,o._id).set("width", 280); });} } function CharacterGet(characterName, msg, charSize, darkvision) { var ShiftCharacter = findObjs({ type: 'character', name: characterName })[0]; //sendChat("", "ShiftChar is: " + ShiftCharacter.get('name')); if(getAttrByName(ShiftCharacter.get('id'), 'npc', 'current') == 1) { //sendChat("", "NPC thing happened"); _.each(msg.selected,function (o) { getObj(o._type,o._id).set({ imgsrc: getCleanImgsrc(ShiftCharacter.get('avatar')), bar1_link: 'None', bar3_link: 'None', represents: ShiftCharacter.id, bar1_value: getAttrByName(ShiftCharacter.get('id'), 'hp', 'max'), bar1_max: getAttrByName(ShiftCharacter.get('id'), 'hp', 'max'), bar3_value: getAttrByName(ShiftCharacter.get('id'), 'npc_ac', 'current'), bar3_current: getAttrByName(ShiftCharacter.get('id'), 'npc_ac', 'current'), light_radius: darkvision, light_dimradius: 0, light_otherplayers: false }); }); } else { //sendChat("", "PC thing happened"); _.each(msg.selected,function (o) { getObj(o._type,o._id).set({ imgsrc: getCleanImgsrc(ShiftCharacter.get('avatar')), represents: ShiftCharacter.id, bar1_value: getAttrByName(ShiftCharacter.get('id'), "hp", 'current'), bar1_max: getAttrByName(ShiftCharacter.get('id'), "hp", 'max'), bar1_link: findObjs({type: "attribute", characterid: ShiftCharacter.get('id'), name: 'hp'})[0].id, bar3_value: getAttrByName(ShiftCharacter.get('id'), "ac", 'current'), bar3_max: getAttrByName(ShiftCharacter.get('id'), "ac", 'max'), bar3_link: findObjs({type: "attribute", characterid: ShiftCharacter.get('id'), name: 'ac'})[0].id, light_radius: darkvision, light_dimradius: 0, light_otherplayers: false }); }); } Size(charSize, msg); } });
1583519408

Edited 1583519917
Any help would be appreciated I think it might just be calling the wrong stat because of a name change or something. Edit: I have narrowed it down to something in the NPC Section only the PC part works fine.
Anthony V. said: Any help would be appreciated I think it might just be calling the wrong stat because of a name change or something. Edit: I have narrowed it down to something in the NPC Section only the PC part works fine. Ugh, I can't figure it out :( so weird
Hey, someone's using my crummy old script! Anyways, I was playing with it, trying to see what's wrong. It turns out, I didn't put any error checking in, so if you've never adjusted the PC's hp (just put 1 in max and current, if you want to test), it won't have an hp attr to check, or something like that.
1583531084

Edited 1583531254
Bast L. said: Hey, someone's using my crummy old script! Anyways, I was playing with it, trying to see what's wrong. It turns out, I didn't put any error checking in, so if you've never adjusted the PC's hp (just put 1 in max and current, if you want to test), it won't have an hp attr to check, or something like that. My players love this script so much! Thank you for your work! I actually am not having an issue with changing to the PC but when trying to change to a new form. For instance I copy an existing beast, "Ape" for example, I change the name to "Druid Ape". But when I run the macro I get the Error from above. Edit: I may be messing something up but that is how I had done it in the past to get it to work.
1583533359

Edited 1583533393
Bast L.
API Scripter
Hmm, just tried it (in a game I made a couple of weeks ago, so probably not a sheet change issue), and it's working for me. Maybe I can hop in to your game later, and check it out (free in a couple of hours).
Bast L. said: Hmm, just tried it (in a game I made a couple of weeks ago, so probably not a sheet change issue), and it's working for me. Maybe I can hop in to your game later, and check it out (free in a couple of hours). That would be great! You're the best I'll PM you GM invite.
Did you get around fixing this? I'm having the same error. Could use an update.
I'm having a similar issue but its not with changing into animals but changing back to the character. Really at a loss here so an update on the solution would be great! Thanks.
1586453452

Edited 1586453488
Bast L.
API Scripter
Sorry, I didn't see the updated questions. Anthony found a fix before I joined, which he said was: I did figure it out, it had to do with me copying the game from another game. If I used a fresh drag and drop from the compendium it worked fine! Not sure if that applies to your situations. If it does, and it fixes it, please let me know. If it doesn't, then I'm really curious.