Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Compatibility with Tactical Grid #43

Open
Ikabodo opened this issue Dec 31, 2023 · 1 comment
Open

Suggestion: Compatibility with Tactical Grid #43

Ikabodo opened this issue Dec 31, 2023 · 1 comment

Comments

@Ikabodo
Copy link

Ikabodo commented Dec 31, 2023

https://github.com/Aedif/tactical-grid/releases/tag/1.19.0

Tactical grid recently added a cool range hover feature. Maybe something to consider adding support for? I looks like the API is pretty straight-forward.

Or do you have hooks for item hover?

@Ikabodo
Copy link
Author

Ikabodo commented Jan 1, 2024

   Hooks.on('action-pack.updateTray', (html) => {
    const getTokensAndItem = async function (uuid) {
      const item = await fromUuid(uuid);
      const embedded = parseUuid(uuid).embedded;
      const tokenId = embedded[embedded.findIndex((t) => t === 'Token') + 1];
      const token = canvas.tokens.get(tokenId);

      let tokens;
      if (token) tokens = [token];
      else tokens = item.actor.getActiveTokens(true);

      return { tokens, item };
    };

    html
      .find('.item-name')
      .on('mouseover', async (event) => {
        const uuid = $(event.target).closest('.item').data('item-uuid');
        const { tokens, item } = await getTokensAndItem(uuid);
        tokens.forEach((t) => TacticalGrid.rangeHighlight(t, { item }));
      })
      .on('mouseleave', async (event) => {
        const uuid = $(event.target).closest('.item').data('item-uuid');
        const { tokens } = await getTokensAndItem(uuid);
        tokens.forEach((t) => TacticalGrid.clearRangeHighlight(t));
      });
  });

Aedif made this worldscript that works great for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant