mclemente / fvtt-module-polyglot

Talk to others using a language you can speak and scrambles text you can't understand.
MIT License
41 stars 48 forks source link

canvas.hud.bubbles.say() with language emote object provided appears not to trigger polyglot #212

Closed napolitanod closed 2 years ago

napolitanod commented 2 years ago

Describe the bug Hello! If I recall correctly, this worked at a point in time in the past, maybe before R9? I am attempting to follow the guide found here: https://github.com/League-of-Foundry-Developers/fvtt-module-polyglot/wiki/Macros for generating a chat bubble that is altered by Polyglot. Note that I am following the instruction just for the chat bubble - I don't want the chat message to generate. I am not seeing the polyglot transform the chat bubble text. It is highly likely I am doing it wrong :(

To Reproduce Steps to reproduce the behavior:

  1. I enter this into the console while having a token targeted: await canvas.hud.bubbles.say(game.user.targets.first(), 'hi', {language: 'dwarvish'})
  2. I also attempted await canvas.hud.bubbles.say(game.user.targets.first(), 'hi', {emote:{language: 'dwarvish'}}), which I think is how the instructions would have it
  3. The text above the token's head is not altered by polyglot

Expected behavior I expected the text in the chat bubble to be translated to dwarvish. When sent over sockets I also expected the same. I also tried orc.

Additional context

napolitanod commented 2 years ago

Edited to indicate that I also tried await canvas.hud.bubbles.say(game.user.targets.first(), 'hi', {emote:{language: 'dwarvish'}}) and await canvas.hud.bubbles.say(game.user.targets.first(), 'hi', {emote:{language: 'orc'}}). I believe following the wiki instruction this is the proper way.

mclemente commented 2 years ago

The example on the Wiki had some mistakes: it lacked the "function" declaration for foo() and result wasn't declared when it should've been a string.

{emote:{language: 'dwarvish'}} is the correct way.

game.user.targets.first() requires you to be targetting a token, not just selecting it. If you try to make a bubble without a token, Foundry just ignores it. If you were targeting a token, it works correctly. You should've just use token instead.

napolitanod commented 2 years ago

Thank you. I am targeting the token when using game.user.targets.first() and I am seeing the chat bubble I just can't get the polyglot to encode the chat into the provided language on my DM session or in the player's session. I'll keep trying things out.

mclemente commented 2 years ago

Oh, I see the error now. It assumes there is a message for the scrambling and it throws errors.

Even with that fixed, I don't see a Chat Bubble being reproduced on other player's screens, and I'm not sure about that one.

napolitanod commented 2 years ago

Oh nice! The chat bubble on another player's screen requires a socket call, which I am also doing. When available, I'll see if the fix makes it show in the other language via the socket call.

mclemente commented 2 years ago

Oh, okay, I was worried something else was broken with the bubbles.

I just pushed a update. It should work for you now.

napolitanod commented 2 years ago

Yes, that did it. Thank you!!!