periodic / foundryvtt-summoner

A module to help with summoning tokens in the Foundry Virtual Tabletop
MIT License
4 stars 1 forks source link

Summon macro doesn't work unless a token is selected #13

Closed Merudo closed 3 years ago

Merudo commented 3 years ago

If I run the following macro:

Summoner.placeAndSummonFromSpell(actor, item, "Flaming Sphere");

It works if a token is selected. If none are selected however, I instead get an error:

summoner.js:210 Uncaught (in promise) TypeError: Cannot read property 'id' of null
    at sendSummonRequest (summoner.js:210)
    at Object.<anonymous> (summoner.js:81)
    at Generator.next (<anonymous>)
    at summoner.js:7
    at new Promise (<anonymous>)
    at __awaiter (summoner.js:3)
    at summoner.js:42
Merudo commented 3 years ago

Nevermind, it works if I change the macro to

Summoner.placeAndSummonFromSpell(item.options.actor, item, "Flaming Sphere");

In Item Macro, actor is the selected actor, while item.options.actor is the actor casting the spell.

periodic commented 3 years ago

Yep, this is probably the most common type of thing that I get requested. I should probably put in a guard to check that first thing is actually an actor. I'll take it as a suggestion and put it in #14