Kekilla0 / Item-Macro

Store macros in your items, execute them from your character sheet or from your favorite automation module!
MIT License
19 stars 21 forks source link

Item Macros don't accept arguments when called via macro #3

Closed BadIdeasBureau closed 4 years ago

BadIdeasBureau commented 4 years ago

(Throwing an issue here, rather than talking on Discord about this)

I think this is possible with some small edits to "executeMacro()" and "runMacro()", but don't have the javascript knowledge to put this into practice. (any code in the following should be assumed to be wrong!)

In runMacro, (line 139 of itemMacro.js), change its arguments to runMacro(_actorID, _itemID, arguments[])

In executeMacro (line 81), change its arguments to executeMacro(_actorID, _itemID, arguments[])

And then change line 102 to }).execute(arguments)

It might need some extra stuff to unpack the arguments from the array before passing them to execute, but it should then allow any macro to call runMacro("Actor", "Item", ["arg0", "arg1", "arg2"]) and have those arguments passed on to the item macro.

Why is this useful? it means that for an item in a shared compendium, you can set up Dynamic Effects to call a macro with specific arguments, and then share this item between worlds without having to also share the macro. (or in my somewhat excessive case, all I would need to share are the non-item-specific helper macros, like the one that applies damage)

Kekilla0 commented 4 years ago

This would also require a dependancy for the Furnace. Not sure if I am 100% on board with that.

Also, pretty sure with Dynamic Effects you are still able to pass the macro arguments to the item macro because DE doesn't actually use any of the Item Macro functions to run. It pulls the command from the flag and just executes it on its own.

BadIdeasBureau commented 4 years ago

Fair enough - hadn't realised that Furnace was what added arguments to macros! Yeah, avoiding that dependency is reasonable. I'll just have to import both an item and a macro for each spell to make my ridiculous workflow work then :P