Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Players unable to execute script macros when applying conditions #692

Open
sealtrowitz opened this issue Jul 15, 2022 · 4 comments
Open
Assignees
Labels
bug Something isn't working ✨ec Enhanced Conditions

Comments

@sealtrowitz
Copy link

Describe the bug
Players are unable to execute script macro via applying a condition with Enhanced Conditions despite having the proper permissions to execute script macros in the world. The macro execution works fine for the GM.

To Reproduce
Steps to reproduce the behavior:

  1. Create any script macro, such as a console.log (actor, token) macro, and set it in the Condition Lab to be executed alongside a certain condition.
  2. When logged in as GM, apply the condition to a token. It should function fine. Remove the condition again.
  3. When logged in as a player, apply the same condition to a token that you own. It does not execute the macro.

Expected behavior
Players should be able to execute script macros via applying conditions when those conditions are set up to do so in the Condition Lab.

Screenshots
n/a (though I can get some if that would help? just tell me what of!)

Environment Info (please complete the following information):

  • Foundry Version: 9.269
  • Game System / Version: LANCER 1.2.0
  • CUB Version 1.9.2
  • Browser Firefox
  • OS Windows 11

Additional context
Specifically, the macros I am trying to get to work are macros that apply/remove TokenMagicFX visual effects. I also tried giving all players ownership permission of the applicable macros within the macro directory, since I thought that might be what was causing them to not execute, but that did not fix it.

@sealtrowitz sealtrowitz added bug Something isn't working unverified Bug not yet validated labels Jul 15, 2022
@eclarke12 eclarke12 added the ✨ec Enhanced Conditions label Jul 23, 2022
@eclarke12 eclarke12 added this to the v1.10.0 milestone Jul 23, 2022
@eclarke12 eclarke12 mentioned this issue Jul 27, 2022
@eclarke12 eclarke12 removed the unverified Bug not yet validated label Jul 28, 2022
@eclarke12
Copy link
Member

The issue here is that Enhanced Conditions logic is proxied through a GM, so any macros associated to a Condition will be executed by/as the GM. However in most cases this should still result in the desired outcome (eg. the TokenMagicFX being applied/removed). There is possibly some other bug causing the context (actor/token) to not be passed correctly.

@eclarke12 eclarke12 removed this from the v1.10.0 milestone Jul 28, 2022
@thatlonelybugbear
Copy link

A video from the Foundry discord that show cases the same issue when executing a secondary macro with no token selected in the GM's client and the macro breaking as a consequence:
https://discord.com/channels/170995199584108546/699750150674972743/1000801560462368839

@dodgepong
Copy link

There's a related "bug" here where, since macros that are triggered by conditions being added/removed are run as GM, that means that any reference to, say, canvas.tokens.controlled specifically refers to whichever tokens are being controlled by the GM. If a player adds or removes a condition from a token, and that triggers a macro to be run, if the GM is selecting a different token than the player, the macro will be run as if the GM's selected token is the triggering token rather than the player's. Or if the GM is selecting no token, then canvas.tokens.controlled is empty even when the player triggering the change is selecting one.

Fortunately it looks like Enhanced Conditions passes the actual token/actor being affected as a parameter, an object that either looks like { token: <affected TokenDocument> } or { actor: <affected Actor> }. In CUB 1.9.2 and earlier, this argument can be accessed in the macro with arguments[0].args[1], or in CUB 1.10 and later it can be accessed with arguments[0].args[0]. At least, that's how I was able to get it to work.

@dodgepong
Copy link

Update: I forgot I had Advanced Macros installed... the above solution will only work with that installed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working ✨ec Enhanced Conditions
Projects
None yet
Development

No branches or pull requests

4 participants