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

Cannot Read Properties of .split in Complex Macros #45

Closed Tarbarian closed 1 year ago

Tarbarian commented 1 year ago

Advanced Macros produces an error when reading .split in complex script macros. Simple uses of .split like the simple macro below work, but more complex macros like applyBuff for PF1e produce the error.

Repo Steps

  1. Using PF1e 0.82.2 and Foundry v10.290, activate libWrapper and Advanced Macros.
  2. Add the linked macro above as a script macro named applyBuff
  3. Use @Macro[applyBuff]{Apply Mage Armor} on a token.

Outcome without Advanced Macros Active: Buff named Mage Armor applied on token/actor

Outcome with Advanced Macros Active: Error below

Error

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split')
[Detected 1 package: advanced-macros]
    at HTMLAnchorElement._onClickContentLink (Macros.js:587)

Simple Macro

const str = 'The quick brown fox jumps over the lazy dog.';

const words = str.split(' ');
console.log(words[3]);
// expected output: "fox"

const chars = str.split('');
console.log(chars[8]);
// expected output: "k"

const strCopy = str.split();
console.log(strCopy);
// expected output: Array ["The quick brown fox jumps over the lazy dog."]
mclemente commented 1 year ago

There was a major rewrite of the module with the latest Pull Request (#44) and that issue was already fixed when I tried to fix it. Next release shall have this issue fixed.