DFreds / dfreds-convenient-effects

A FoundryVTT module that adds easy to use toggleable active effects for any system.
MIT License
47 stars 39 forks source link

Have CE turn on and off Visual Effects from Token Magic macros hosted locally in addition to the effects found in the Token Magic Compendium #244

Closed TeacherBobK closed 1 year ago

TeacherBobK commented 1 year ago

Is your feature request related to a problem? Please describe. Big fan of your Foundry modules. When a condition is implemented using CE and references a Token Magic effect (lets say blur) the visual effect works properly and when the condition is removed using CE the visual effect is removed without removing any other visual effect that token might have. This part works properly and there is no problem. The issue is this...

... I take the Token Magic effect and put it in my local macro collection (so that I might make a very minor change - like to change the color), CE implements the condition and visual effect properly but when I use use CE to stop the effect the visual effect is not turned off as it is when in the Token Magic macro folder (or compendium). I do change the CE from macro.tokenMagic (); custom; blur to macro.execute (); custom; blur.

Clearly I can use the Token Magic macro to remove visual effect but it removes all the visual effects on that token. I would love to be selective as I can using the default conditions in CE.

Describe the solution you'd like It would be wonderful if local macros that reference Token Magic visual effects being used can be turned on and off using the CE system. (If it already can you point me in the right direction to what I am might be doing wrong)

Describe alternatives you've considered I added code to the end of the local Blur macro (called Blurtest so that I know which macro is which) that when executed it implements the visual effect and when executed again it turns that visual effect off without turning off any other visual effect that might be on the token. This extra code does not work well with CE.

Additional context I am using the 5e system and am at the current version of both Foundry and CE.

If this is a known problem or already in the pipeline to implement then I thank you for putting out wonderful projects that make my D&D games run very smoothly. (what I am asking is a QoL issue and not a big issue at all).

Thank you again for the great products.

DFreds commented 1 year ago

Hm, I could be mistaken, but macro.execute simply executes anything you add in that macro. It doesn't inherently do anything like toggling on or off a token magic effect, because it isn't smart enough to do that. macro.tokenMagic is smart enough to do that, because it's implemented by DAE and probably does it for you. You would have to do some sort of check in the macro itself in order to do that.

You can see how DAE does it in these general files: https://gitlab.com/tposney/dae/-/blob/v10/src/module/Systems/DAEdnd5e.ts#L1100 https://gitlab.com/tposney/dae/-/blob/v10/src/module/GMAction.ts#L194

globalThis.TokenMagic has some methods on it as well. You could probably use hasFilterId.

globalThis.TokenMagic
{addFilters: ƒ, addFiltersOnSelected: ƒ, addFiltersOnTargeted: ƒ, addUpdateFilters: ƒ, addUpdateFiltersOnSelected: ƒ, …}
addFilters: async ƒ addFilters(placeable, paramsArray, replace = false)
addFiltersOnSelected: async ƒ addFiltersOnSelected(paramsArray, replace = false)
addFiltersOnTargeted: async ƒ addFiltersOnTargeted(paramsArray, replace = false)
addPreset: async ƒ addPreset(presetName, params, silent = false)
addUpdateFilters: async ƒ addUpdateFilters(placeable, paramsArray)
addUpdateFiltersOnSelected: async ƒ addUpdateFiltersOnSelected(paramsArray)
addUpdateFiltersOnTargeted: async ƒ addUpdateFiltersOnTargeted(paramsArray)
deleteFilters: async ƒ deleteFilters(placeable, filterId = null)
deleteFiltersOnSelected: async ƒ deleteFiltersOnSelected(filterId = null)
deleteFiltersOnTargeted: async ƒ deleteFiltersOnTargeted(filterId = null)
deletePreset: async ƒ deletePreset(presetName, silent = false)
exportPresetLibrary: ƒ exportPresetLibrary(exportName = "tmfx-presets")
exportTemplateSettings: ƒ exportTemplateSettings(exportName = "tmfx-template-settings")
getControlledPlaceables: ƒ getControlledPlaceables()
getPlaceableById: ƒ getPlaceableById(id, type)
getPreset: ƒ getPreset(presetName)
getPresets: ƒ getPresets(libraryName = PresetsLibrary.MAIN)
getTargetedTokens: ƒ getTargetedTokens()
hasFilterId: ƒ hasFilterId(placeable, filterId)
hasFilterType: ƒ hasFilterType(placeable, filterType)
importPresetLibrary: async ƒ importPresetLibrary()
importPresetLibraryFromPath: async ƒ importPresetLibraryFromPath(path, options = {})
importPresetLibraryFromURL: async ƒ importPresetLibraryFromURL(url, options = {})
importTemplateSettings: async ƒ importTemplateSettings()
importTemplateSettingsFromPath: async ƒ importTemplateSettingsFromPath(path, options = {})
resetPresetLibrary: async ƒ resetPresetLibrary()
updateFilters: async ƒ updateFilters(paramsArray)
updateFiltersByPlaceable: async ƒ updateFiltersByPlaceable(placeable, paramsArray)
updateFiltersOnSelected: async ƒ updateFiltersOnSelected(paramsArray)
updateFiltersOnTargeted: async ƒ updateFiltersOnTargeted(paramsArray)
_assignFilters: ƒ _assignFilters(placeable, filters, bulkLoading = false)
_cachedContainer: e {_events: i, _eventsCount: 0, tempDisplayObjectParent: null, transform: t, alpha: 1, …}
_checkFilterId: ƒ _checkFilterId(placeable, filterId, flags)
_clearImgFiltersByPlaceable: ƒ _clearImgFiltersByPlaceable(placeable, filterId = null)
_getAnimeMap: ƒ getAnimeMap()
_getPresetTemplateDefaultTexture: ƒ _getPresetTemplateDefaultTexture(presetName, presetLibrary = PresetsLibrary.TEMPLATE)
_loadFilters: ƒ _loadFilters(placeables, bulkLoading = true)
_singleLoadFilters: ƒ _singleLoadFilters(placeable, bulkLoading = false)
_updateFilters: ƒ _updateFilters(data, options, placeableType)
_updateTemplateData: ƒ _updateTemplateData(data, options, placeableType)
[[Prototype]]: Object