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

TypeError: Cannot read property 'get' of undefined Concentration API

October 31 (3 years ago)

Edited October 31 (3 years ago)

I am getting this error when I cast a concentration spell.

TypeError: Cannot read property 'get' of undefined at handleConcentrationSpellCast (apiscript.js:5557:89) at handleInput (apiscript.js:5426:13) 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:1736: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) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)


Here are the scripts I am currently running with it, and below is the macro I use to select haste from. I am just using the base 5E by roll20 character sheet



@{wtype} &{template:default}{{name=@{selected|character_name} Spellcasting
}}{{Spell Save DC @{selected|spell_save_dc}= @{selected|spell_attack_bonus} to hit with spell attacks
}}{{Cantrip
=[@{Selected|repeating_spell-cantrip_$0_spellname}](~Selected|repeating_spell-cantrip_$0_spell)
[@{Selected|repeating_spell-cantrip_$1_spellname}](~Selected|repeating_spell-cantrip_$1_spell)
[@{Selected|repeating_spell-cantrip_$2_spellname}](~Selected|repeating_spell-cantrip_$2_spell)
[@{Selected|repeating_spell-cantrip_$3_spellname}](~Selected|repeating_spell-cantrip_$3_spell)
[@{Selected|repeating_spell-cantrip_$4_spellname}](~Selected|repeating_spell-cantrip_$4_spell)
[@{Selected|repeating_spell-cantrip_$5_spellname}](~Selected|repeating_spell-cantrip_$5_spell)
}}{{1st Level
=[@{Selected|repeating_spell-1_$0_spellname}](~Selected|repeating_spell-1_$0_spell)
[@{Selected|repeating_spell-1_$1_spellname}](~Selected|repeating_spell-1_$1_spell)
[@{Selected|repeating_spell-1_$2_spellname}](~Selected|repeating_spell-1_$2_spell)
}}{{2nd level
=[@{repeating_spell-2_$0_spellname}](~selected|repeating_spell-2_$0_spell)
[@{repeating_spell-2_$1_spellname}](~selected|repeating_spell-2_$1_spell)
}}{{3rd level
=[@{repeating_spell-3_$0_spellname}](~selected|repeating_spell-3_$0_spell)
[@{repeating_spell-3_$1_spellname}](~selected|repeating_spell-3_$1_spell)
}}{{4th level
=[@{repeating_spell-4_$0_spellname}](~selected|repeating_spell-4_$0_spell)
[@{repeating_spell-4_$1_spellname}](~selected|repeating_spell-4_$1_spell)
}}{{5th level
=[@{repeating_spell-5_$0_spellname}](~selected|repeating_spell-5_$0_spell)
[@{repeating_spell-5_$1_spellname}](~selected|repeating_spell-5_$1_spell)
}}{{6th level
=[@{repeating_spell-6_$0_spellname}](~selected|repeating_spell-6_$0_spell)
}}{{7th level
=[@{repeating_spell-7_$0_spellname}](~selected|repeating_spell-7_$0_spell)
}}

October 31 (3 years ago)

Edited October 31 (3 years ago)
Oosh
Sheet Author
API Scripter

Do you have any non-word characters in your character name? If so, try removing them so you only have letters and see if it works.

Also, is this for a player character or for NPCs? The script won't work for NPC's unless their character name is set to display on templates. It should work for PC's regardless of the setting.

When you type @{selected|charname_output} into chat, do you get charname=<yourNameHere> ? If it doesn't look like that with your character name spelled correctly, try toggling the name display setting on the settings tab, it might have somehow got a bad value in it.


I'm pretty sure this is the part that's failing:

        let character_name = msg.content.match(/charname=([^\n{}]*[^"\n{}])/);            
        character_name = RegExp.$1;

            characterid = findObjs({ name: character_name, _type: 'character' }).shift().get('id'),


If it can't find the string 'charname=', or if the part it grabs afterwards isn't you character name, the findObjs() will fail.

One last option is that it's finding too much after charname. If you've got anything attached to the end of the spell macro that follows on from the charname part and isn't a standard {{ template }} property, it might be getting bundled up with the character name.

Thank you, I didn't have the show template ticked, and had a few spelling issues around case sensitivity, but it seems to be working for my NPCs now. Thanks