mclemente / fvtt-advanced-macros

Use handlebars templating, recursive macro calls and call macros with arguments or directly from chat.
MIT License
15 stars 9 forks source link

endCombat Error #24

Closed mrjaksauce closed 2 years ago

mrjaksauce commented 2 years ago

Hello! I get an error when running this macro piece here:

if (img.slice(0,-Math.abs(aName.length)) + (currentSide == 'a' && token.inCombat === true)) await game.combat.endCombat();

image

Just checking if this is an "advanced macro" issue or, more likely, my coding around this endCombat bit?

Thanks!

mclemente commented 2 years ago

Are you running this without any combat in the Combat Tracker? It will be null, so you won't be able to call endCombat()

mrjaksauce commented 2 years ago

I fixed it! Thanks for the input, I needed a little bit more adjusting around what you said.

Thank you again! I was right, it was me :)

mrjaksauce commented 2 years ago

This is what I ended up with:

if (token.data.img === sideA && token.inCombat === true)//Has the macro changed the side to sideA? End combat. { await game.combat.endCombat(); } else if (token.data.img === sideB && token.inCombat === false)//Has the macro changed the side to sideB? Turn on combat. { await token.toggleCombat(); game.combat.rollNPC( {rollMode: 'gmroll' } ); //Roll the NPC initiative, hiding it with GM Roll option }