PDA

View Full Version : Extension[CoreRPG]: display NPC tokens as portraits in chat



sirnoobsauce
January 8th, 2022, 01:27
This is a fairly straightforward extension for CoreRPG in FGU (I haven't tested in FGC, no idea if it would work) to add NPC tokens to the chat when speaking as NPCs. I have wanted that feature for a while, but from some searches on the forums I couldn't find anyone else having done an extension for that.

I saw some other posts from people asking is such an extension existed though, so I decided to share this since some other people seem to have wanted the same feature.

I have only tested it with basic CoreRPG, 5e and a couple of Modiphius 2d20 rulesets. But in theory, it should work for other rulesets that extend CoreRPG as long as they store NPC names under the "name" element and the token string under the "token" element. And as long as they don't implement their own chat handling that changes the tokens back via a ChatManager message handler.

And as a usage note: It only works as long as the chat identity exactly matches the NPC name (so as long as you don't modify the NPC name after activating the identity, that is no issue).

It also applies when the GM speaks with a player character's identity (their chats will have the appropriate portrait).

As of v2.0, it also supports dice rolls, entities in the combat tracker, and NPCs imported from modules.

The current version is available here:

https://github.com/bakermd86/NPCPortraits/releases/latest
https://forge.fantasygrounds.com/shop/items/509/view

Attached is an example of what the extension looks like when in use.

--Edit--

I added an option to also register additional datatypes with the portrait extension so that you can have tokens in chat for any datatypes that have a "name" field for their speaking identity, and a "token" field containing a token. To use that in your own extensions/rulesets/whatever, you just need to call: NPCPortraitManager.registerDataType("class")

In an onDesktopInit function. The simplest way is just to have a global script set an Interface.onDesktopInit callback:


Interface.onDesktopInit = onDesktopInit

And then register any data types from within that callback. For example (taken from my STA ruleset):



function onInit()
Interface.onDesktopInit = onDesktopInit
end

function onDesktopInit()
-- Register crewmate record type with NPCPortraitManager
if NPCPortraitManager and NPCPortraitManager.registerDataType then
NPCPortraitManager.registerDataType("crewmate")
end
end


50843

- Updated 01/08/22 to work with Savage Worlds ruleset after being told it didn't work
- Updated 01/30/22 to add link to Github release page
- Updated 02/18/22 to add link to the Forge

damned
January 8th, 2022, 01:34
Very good. I was doing something along these lines in one of my projects.

MeAndUnique
January 8th, 2022, 07:12
Very nice! Any plans to put this on the forge?

redba
January 8th, 2022, 08:06
HI sirnoobsauce,
well done and very helpful so thanks a lot..

YAKO SOMEDAKY
February 10th, 2022, 13:38
A genius finally did something I always wanted and never knew how to do! Now we will have more "personality" in chat dialogs! To make it even better, we just need to read a post that was added to the dice roll script to show the NPC portrait, then it would be perfect!

kevininrussia
February 10th, 2022, 21:27
Working in 4E. Thanks!

srbongo
February 11th, 2022, 00:26
My chat-only RP-heavy game thanks you for this.

kevininrussia
February 11th, 2022, 02:18
As Yako2020 mentioned, have you investigated if this technology would work on NPC to-hit and damage roll chat readouts? Replacing the GM icon.

https://i.imgur.com/kiV1IvG.png

Ludd_G
February 11th, 2022, 10:11
As Yako2020 mentioned, have you investigated if this technology would work on NPC to-hit and damage roll chat readouts? Replacing the GM icon.

https://i.imgur.com/kiV1IvG.png

That would be awesome!

sirnoobsauce
February 16th, 2022, 21:07
Thanks for the suggestion on the attack/damage rolls, I did a quick implementation of that and updated the latest version available above. I tested in 5e, SavageWorlds and my own Star Trek Adventures ruleset, and it seemed to work OK, that is available here:

https://github.com/bakermd86/NPCPortraits/releases/latest

Ulric
February 17th, 2022, 03:18
Thanks for the suggestion on the attack/damage rolls, I did a quick implementation of that and updated the latest version available above. I tested in 5e, SavageWorlds and my own Star Trek Adventures ruleset, and it seemed to work OK, that is available here:

https://github.com/bakermd86/NPCPortraits/releases/tag/latest
Your link goes 404. I downloaded version 1.6 and tried it withte Starfinder ruleset. The Player images are displayed in Chat but NPC's only display as GM.

kevininrussia
February 17th, 2022, 06:56
Thanks for the suggestion on the attack/damage rolls, I did a quick implementation of that and updated the latest version available above. I tested in 5e, SavageWorlds and my own Star Trek Adventures ruleset, and it seemed to work OK, that is available here:

https://github.com/bakermd86/NPCPortraits/releases/tag/latest

Works great in 4E

Thank you!

sirnoobsauce
February 17th, 2022, 11:29
Your link goes 404. I downloaded version 1.6 and tried it withte Starfinder ruleset. The Player images are displayed in Chat but NPC's only display as GM.

I fixed the link. I tested with Starfinder though, and it seems to work fine (at least in FGU, I haven't tested it at all in FGC):

51529

Ludd_G
February 17th, 2022, 12:19
Hi,

Unfortunately I can confirm that in 5e, FG Unity, with no other extensions loaded, "Fen's NPC Portrait Workaround v1.6" isn't showing the NPC token. It does show the PC token though.

Cheers,

Simon

sirnoobsauce
February 17th, 2022, 14:00
Hi,

Unfortunately I can confirm that in 5e, FG Unity, with no other extensions loaded, "Fen's NPC Portrait Workaround v1.6" isn't showing the NPC token. It does show the PC token though.

Cheers,

Simon

It works in 5e for me (51534). What OS are you running FGU on? The fact it is working for PCs but not NPCs indicates that the issue is probably with the dummy portraits being created. Basically: the chat window in FG cannot display a regular image, it can only display "portraits" which are created only for user identities. So in order to display NPC tokens in chat, the extension is actually creating a dummy charsheet entry (with a special node name to avoid conflicts with real charsheets) and then deleting it. In my testing, deleting the charsheet does not clean up the portrait right away (the portrait is cleaned up when loading a campaign though, so the dummies are created each time in an onDesktopInit function).

If you load a campaign with the extension active and then go to the campaign portraits folder (%appdata%/SmiteWorks/Fantasy Grounds/campaigns/<campaign name>/portraits) you should see entries with names like "dummy_portrait_npc_id-#####" for each NPC with a token in your campaign. Like this: 51535.

Given what you and Ulric are reporting, this implies that the code to insert the portraits is working fine (since PCs and NPCs use mostly the same code) but that something in your environment is causing the portraits to be cleaned up when the dummy identities are deleted. If that is the case, then the portraits folder here would not contain the dummy_portrait_npc... entries. If you can confirm that, and let me know what OS/platform you are using, I can see if I can reproduce in my environment and see if maybe there is another workaround to keep the portraits from being deleted.

The entire mechanism is a big kludge to workaround the limitation of the chat not being able to display arbitrary images. It would also be a lot easier if the User package provided a direct call to create an arbitrary portrait from an image, rather than it being tied to an identity. If some platforms are deleting the portraits right away when deleting an identity, then I would have to leave the identities in place and filter them out of the character select window somehow...

Ludd_G
February 17th, 2022, 14:22
Hi,

I'm on Window 10, and I do see a 'dummy_portrait_npc_id-00001' file in the campaign's portrait folder. I only have 1 NPC on the CT for testing.

Thanks for all your work on this, it's much appreciated!

Cheers,

Simon

Ulric
February 18th, 2022, 03:03
I fixed the link. I tested with Starfinder though, and it seems to work fine (at least in FGU, I haven't tested it at all in FGC):

51529
Thanks for taking a look at the problem. I really like your extension. I looked at your screenshot and noticed the NPCs you used in your test were GM created. I did another test with "Venture Captain Vickr" which is a player and it displays correctly. I then added my GM created NPC "Absalom Station Male citizen" to the CT and I could get thisNPC's image to display correctly in the chat. However, NPCs from purchased content like the "Aeon Guard" will not display correctly. I have attached a screenshot demonstrating the problem. I tested with FGU fully updated and only your extension running.

YAKO SOMEDAKY
February 18th, 2022, 03:30
Thanks! I'm going to test it with my extension in Rolemaster, I think I'll have to make some adjustments to my extension! But your extension + mine + player controlling NPC will be PERFECT!

sirnoobsauce
February 18th, 2022, 18:01
Many thanks to Ludd_g and Ulric for their feedback. I made a number of changes to improve performance, improve handling for rolls, support modules, and support entries in the combat tracker. I also uploaded it to the Forge:

https://forge.fantasygrounds.com/shop/items/509/view

Ulric
February 18th, 2022, 20:18
Many thanks to Ludd_g and Ulric for their feedback. I made a number of changes to improve performance, improve handling for rolls, support modules, and support entries in the combat tracker. I also uploaded it to the Forge:

https://forge.fantasygrounds.com/shop/items/509/view
Thanks for all your efforts. I sent you a PM concerning a v2.0 bug.

Mike Serfass
February 19th, 2022, 05:58
Thanks for making this extension! I use it in Savage Worlds.
It used to work fine in Savage Worlds, but version 2 no longer does. It works for the GM speaking as an NPC, but not when speaking for PCs.
Also, since version 2, when clicking the speak icon of an ally NPC from a player character's sheet, the name is not added to the speaker identity drop down in chat.
Version 1.4 works fine in Savage Worlds.
I can provide more details if you like. I'm willing to do more testing is Savage Worlds for you.
Keep up the good work! It's appreciated.

sirnoobsauce
February 19th, 2022, 18:49
Thanks for the report, I uploaded a new version that should fix those issues (also uploaded to the forge):

https://github.com/bakermd86/NPCPortraits/releases/latest

I did a quick test on SWD and it seems to fix those 2 bugs you found. It seems that SWD has its own identity manager, so I had to add special handling for that ruleset specifically in order to accommodate. Most likely, there will be other rulesets that do non-standard stuff requiring special handling as well. But 2.1 should work okay for SWD now.

Mike Serfass
February 20th, 2022, 04:01
Thanks for fixing this so quickly. Except...

I should have been more specific. I'm running the SWADE version of Savage Worlds.
So the update didn't fix SWADE. Now, in addition to the above bugs, it's displaying the token rather than the portrait. And it's stuck on the first character's token. No matter who speaks, it's using the fist character's token all the time.

One step forward, two steps back.
But it's good that SWD has been fixed; that version is still played.

btw, Pathfinder for Savage Worlds uses SWADE, so they'll see the same bugs. But once you fix it for SWADE, it will be fixed for SWPF.

YAKO SOMEDAKY
February 20th, 2022, 12:24
I don't know if it would be possible but after what has been done, I believe so.
The character sheets contain Portrait (which is what appears in the chat when we perform "tests") and also contains the Token (which is the representation of the character in battle maps). With its extension we had the immense advance of being able to customize our NPCs by inserting portraits for them and these appearing in the chat, but the question is could we have portraits for rolls and tokens for battle maps, as we have with players?

kevininrussia
February 21st, 2022, 00:21
Ruleset 4e:

I notice in Console during player login a long list of data being sent to Client (taking some minutes)

Example:

NETWORK RECV FILE REQUEST: campaign/portraits/dummy_portrait_npc_id-00094
NETWORK FILE CACHE MATCH: campaign/portraits/dummy_portrait_npc_id-00094 (75300)

Is there a way of cashing this on client to reduce this transfer time or should I delete any unused portraits to speed up the process?

Mike Serfass
February 21st, 2022, 02:23
@sirnoobsauce: here are the attachments I couldn't add in the message:

sirnoobsauce
February 21st, 2022, 18:44
Ruleset 4e:

I notice in Console during player login a long list of data being sent to Client (taking some minutes)

Example:

NETWORK RECV FILE REQUEST: campaign/portraits/dummy_portrait_npc_id-00094
NETWORK FILE CACHE MATCH: campaign/portraits/dummy_portrait_npc_id-00094 (75300)

Is there a way of cashing this on client to reduce this transfer time or should I delete any unused portraits to speed up the process?

It should only have to replicate the portraits that are in-use (at least as of 2.0, in the earlier versions it would actually pre-create portraits for every single NPC and charsheet record in the entire campaign, which causes very poor performance). On the current version, there shouldn't be that many portraits being replicated (unless you have just a huge number of identities in use when the clients connect).

But because of a couple of quirks of FG there isn't much I can do about the clients having to download them each time. So basically: the chat doesn't support tokens, only portraits. But the only way to dynamically create a portrait in FG is to create an identity and set it there via the User interface. But I have to then delete the actual identity right away, because otherwise they would show up in the Character Select and massively clutter up the campaign. So as a result, the host instance is creating all of the portraits dynamically at runtime, and then those portraits have to be pushed to the clients each time.

kevininrussia
February 22nd, 2022, 00:57
It should only have to replicate the portraits that are in-use (at least as of 2.0, in the earlier versions it would actually pre-create portraits for every single NPC and charsheet record in the entire campaign, which causes very poor performance). On the current version, there shouldn't be that many portraits being replicated (unless you have just a huge number of identities in use when the clients connect).

But because of a couple of quirks of FG there isn't much I can do about the clients having to download them each time. So basically: the chat doesn't support tokens, only portraits. But the only way to dynamically create a portrait in FG is to create an identity and set it there via the User interface. But I have to then delete the actual identity right away, because otherwise they would show up in the Character Select and massively clutter up the campaign. So as a result, the host instance is creating all of the portraits dynamically at runtime, and then those portraits have to be pushed to the clients each time.

<version>1.6</version>

oops :-) Added by Forge now.

Thanks for the info!

Mike Serfass
February 22nd, 2022, 03:07
It seems like displaying a token should be something FGU can do, since it's a similar image type as portraits.
I added a request to Idea Informer: Add Support for Tokens to Chat (https://fgapp.idea.informer.com/proj/fgapp?ia=138301)

Mike Serfass
February 22nd, 2022, 05:34
The update that goes in after today makes this extension work well with SWADE. I very much recommend it, especially if you have players like mine that really like their character portraits.

Ulric
February 22nd, 2022, 14:05
I ran my Starfinder campaign last night using this extension. We had no issues with the extension and my players loved how easy it was to see who took and action or made a comment.

srbongo
February 25th, 2022, 14:02
... However, NPCs from purchased content like the "Aeon Guard" will not display correctly. I have attached a screenshot demonstrating the problem. I tested with FGU fully updated and only your extension running.

This is happening in PF1.0 as well, did you find any workaround?

sirnoobsauce
February 25th, 2022, 14:57
This is happening in PF1.0 as well, did you find any workaround?

For the issue affecting modules in general, that is fixed in the latest versions (2.0+). I did a quick test in PF1E, and there is a default included module called "Well Met in Kith'takharos" which did not work. I looked into why, and the issue is actually just specific to this module name. It fails because the ' character in the module name is part of the DB node path to the NPCs. That exposes an edge case in the portrait creation logic which causes it to fail. Is that the same module you are testing (or really any module with special characters in the name)? If so, give this version a try:

https://github.com/bakermd86/NPCPortraits/raw/master/NPC_Portraits.ext

I added improved input sanitation for DB node paths that should avoid this (and other) edge cases. If that works, let me know and I can update the version in the Forge.

srbongo
February 25th, 2022, 19:25
For the issue affecting modules in general, that is fixed in the latest versions (2.0+). I did a quick test in PF1E, and there is a default included module called "Well Met in Kith'takharos" which did not work. I looked into why, and the issue is actually just specific to this module name. It fails because the ' character in the module name is part of the DB node path to the NPCs. That exposes an edge case in the portrait creation logic which causes it to fail. Is that the same module you are testing (or really any module with special characters in the name)? If so, give this version a try:

https://github.com/bakermd86/NPCPortraits/raw/master/NPC_Portraits.ext

I added improved input sanitation for DB node paths that should avoid this (and other) edge cases. If that works, let me know and I can update the version in the Forge.

The issue affected most modules, the free one you mention included. I'm not sure if it was because of the ' character, these modules were Vaulted purchases from the FG store (Curse of the Crimson Throne and Rise of the Runelords, ect). Each usually contains a , for what it's worth. However, the fix you provided works for me - and solves any issues I was having.

Thanks so much for this, I run a chat-only game and it's a wonder for immersion!

GKEnialb
February 27th, 2022, 01:31
Hi,

I'm on Window 10, and I do see a 'dummy_portrait_npc_id-00001' file in the campaign's portrait folder. I only have 1 NPC on the CT for testing.

Thanks for all your work on this, it's much appreciated!

Cheers,

Simon

I'm seeing the same with only this extension loaded, 5E, Windows 11, and do have dummy_portrait_combattracker_list_id-00002. The portrait is shown in the chat, but not the attacks and damage on the client.

51684

The chat on the left and combat tracker is the GM instance and the chat on the right is the client instance.

GKEnialb
February 27th, 2022, 02:01
And here's the log, if it's interesting (no warnings or errors, but you can see what modules are loaded).

srbongo
February 28th, 2022, 14:59
... The portrait is shown in the chat, but not the attacks and damage on the client. ...

I think this is intended. With "Show GM Rolls" set to off the players only get the Hit/Damage notification and don't see the roll itself, which is what the portrait is attached to.

This is what I gather from post #8 (https://www.fantasygrounds.com/forums/showthread.php?72037-Extension-CoreRPG-display-NPC-tokens-as-portraits-in-chat&p=639789&viewfull=1#post639789)

GKEnialb
March 2nd, 2022, 02:27
I think this is intended. With "Show GM Rolls" set to off the players only get the Hit/Damage notification and don't see the roll itself, which is what the portrait is attached to.

This is what I gather from post #8 (https://www.fantasygrounds.com/forums/showthread.php?72037-Extension-CoreRPG-display-NPC-tokens-as-portraits-in-chat&p=639789&viewfull=1#post639789)

Yep, that's what's happening. If I show GM rolls (which I won't do really in a session), the portraits appear. Thanks.

sirnoobsauce
March 14th, 2022, 21:00
Yep, that's what's happening. If I show GM rolls (which I won't do really in a session), the portraits appear. Thanks.

Yeah, I took a look at this: The secondary damage/hit notifications don't have a sender, just a target. So I would have no way of knowing what token to insert. Also, already have an icon set on them (the sword/blood icons), so that would be problematic to replace the sword/blood icons. FG has no way to display 2 different icons in a chat message.

If you want to reveal the roll itself without setting the global show GM rolls option, you can middle-mouse click on the hidden message to reveal it on a per-message basis. And those revealed roll messages should have the token in them.

GKEnialb
March 15th, 2022, 02:25
Yeah, I took a look at this: The secondary damage/hit notifications don't have a sender, just a target. So I would have no way of knowing what token to insert. Also, already have an icon set on them (the sword/blood icons), so that would be problematic to replace the sword/blood icons. FG has no way to display 2 different icons in a chat message.

If you want to reveal the roll itself without setting the global show GM rolls option, you can middle-mouse click on the hidden message to reveal it on a per-message basis. And those revealed roll messages should have the token in them.

Okay, makes sense. Appreciate you looking into it!

Idward
March 20th, 2022, 23:06
Is there any chance to get this to work when you have a language selected?

johniba
March 21st, 2022, 03:14
Thanks for this extension... it is awsome.
I always wondered why FG doesnt do this by default

Mazzar
April 5th, 2022, 05:59
I seem to be getting an issue where once I roll a PC's Skill (Investigation for example), then I try to chat using Speak as PC, it no longer shows the token. Using 5E ruleset.

To duplicate:
1) Go to PC's Character sheet and select Speak as PC
2) Type Hello in chat (it works
3) Go to the PC's Skills tab and roll a skill check (it works)
4) Type Hello as the PC in chat again. (not it won't show the portrait in chat)

sirnoobsauce
April 12th, 2022, 18:49
I seem to be getting an issue where once I roll a PC's Skill (Investigation for example), then I try to chat using Speak as PC, it no longer shows the token. Using 5E ruleset.

To duplicate:
1) Go to PC's Character sheet and select Speak as PC
2) Type Hello in chat (it works
3) Go to the PC's Skills tab and roll a skill check (it works)
4) Type Hello as the PC in chat again. (not it won't show the portrait in chat)

Yup, looks like a clear cut bug. Thanks for the report. I did a quick fix today and posted to the Forge and here (https://github.com/bakermd86/NPCPortraits/releases/latest).

Mazzar
April 12th, 2022, 20:41
Yup, looks like a clear cut bug. Thanks for the report. I did a quick fix today and posted to the Forge and here (https://github.com/bakermd86/NPCPortraits/releases/latest).

Confirmed that it now works. Thank you!

JoshuaBarbeau
April 27th, 2022, 03:50
Is there any chance to get this to work when you have a language selected?

Came here to say exactly this. Love this extension, but since I only ever speak using the text chat in character IF I am using the language function, it basically doesn't work for me.

rhagelstrom
May 3rd, 2022, 17:36
This extension is really nice. Thank you for this!

MostTornBrain
May 4th, 2022, 03:56
Came here to say exactly this. Love this extension, but since I only ever speak using the text chat in character IF I am using the language function, it basically doesn't work for me.

I was fiddling with the github code for this extension, and I think I have a solution for handling portraits when chatting in languages.

If you add the following to the onDesktopInit() function:
if User.isHost() then
origCommDeliverOOBMesssage = Comm.deliverOOBMessage;
Comm.deliverOOBMessage = myDeliverOOBMessage;
end

And then add this new function, it should display the character portraits for language chat.


function myDeliverOOBMessage(msg, extra)
if (msg.type == LanguageManager.OOB_MSGTYPE_LANGCHAT) then
insertPortraitToMessage(msg, extra);
end
origCommDeliverOOBMesssage(msg, extra);
end


The challenge was the LanguageManager registers a callback for the ChatManager DeliverMessageCallback and it takes precedence over any callback added by an extension, so the portrait insertion had to be handled afterwards. The LanguageManager calls Comm.deliverOOBMessage after it does the "translation" of a language chat message, so we need to intercept that call, insert the portrait, and then call the real OOBMessage function.

Also, for this work-around, the portrait should only be inserted if the message is originating on the GM host - if a real player is chatting in a language, the icon should already be correct and if the insertPortraitMessage() function were to be called by a player, it instead turns the icon into the GM's token.

It all seems to work in my local testing, but I'd recommend more extensive testing in case I overlooked something.

Cheers,
Brian

Lord Skrolk
July 29th, 2022, 18:16
Getting Error messages since last FGU update.

EadtheHead
October 7th, 2022, 03:45
I've just tried this extension in FGU with the AD&D 2nd Edition ruleset. It seems like it works fine in most aspects, but whenever I drop a monster or NPC into the combat tracker from the monster manual it gives an error to any players in the game and on the combat tracker.

EDIT: It's actually not this extension. I disabled this one and then we tested it again and the error stopped and didn't happen again for a couple of days, but then it happened again just yesterday near the end of our session for some reason. My bad, and thanks for the good work on the extension.

PGrimstrup
January 2nd, 2023, 07:51
Hi there. Extension doesn't seem to be working with the Mongoose Traveller 2nd Edition ruleset. It looks like it create the temp image fine (in the campaign portraits folder I see a dummy_portrait_reference-npcdata-name-module, which if I add a .png extension I can view in an image editor), but no image shows in the chat window. I notice without the extension loaded, I get the Imperial Sunburst.

Running on FGU Ultimate 4.3.2, Windows 11. New user to FG, long time Software Developer. Lua is not my strongest language. Let me know if you need any other info.

WinterSoldier7
February 19th, 2023, 19:27
Hello, forgive me for not being able to work this out myself; if I, as GM, talk in the chat as an NPC, will it show the PC's the portrait then?

Update: Ignore me. Wasn't working before because I was an idiot, but it works now!

MrDDT
February 20th, 2023, 03:46
Thanks for this is awesome.

JoshuaBarbeau
March 29th, 2023, 17:24
I was fiddling with the github code for this extension, and I think I have a solution for handling portraits when chatting in languages.

If you add the following to the onDesktopInit() function:
if User.isHost() then
origCommDeliverOOBMesssage = Comm.deliverOOBMessage;
Comm.deliverOOBMessage = myDeliverOOBMessage;
end

And then add this new function, it should display the character portraits for language chat.


function myDeliverOOBMessage(msg, extra)
if (msg.type == LanguageManager.OOB_MSGTYPE_LANGCHAT) then
insertPortraitToMessage(msg, extra);
end
origCommDeliverOOBMesssage(msg, extra);
end


The challenge was the LanguageManager registers a callback for the ChatManager DeliverMessageCallback and it takes precedence over any callback added by an extension, so the portrait insertion had to be handled afterwards. The LanguageManager calls Comm.deliverOOBMessage after it does the "translation" of a language chat message, so we need to intercept that call, insert the portrait, and then call the real OOBMessage function.

Also, for this work-around, the portrait should only be inserted if the message is originating on the GM host - if a real player is chatting in a language, the icon should already be correct and if the insertPortraitMessage() function were to be called by a player, it instead turns the icon into the GM's token.

It all seems to work in my local testing, but I'd recommend more extensive testing in case I overlooked something.

Cheers,
Brian

Hey Brian, thanks for your helpful reply! Can't believe it took me almost a year to see it. Unfortunately, I've no idea where to go to input that piece of code... Don't suppose you can help again?

And if the extension author is watching, would be superb if you could incorporate this function into the default extension...

sirnoobsauce
March 29th, 2023, 20:13
I also completely missed the report of issues with the languages. I had my third baby around that time and moved internationally a few months after. Sorry about that, the fix is actually super easy and only took a few minutes. It is up on the Forge or available here (https://github.com/bakermd86/NPCPortraits/releases/tag/v2.2.3) if you prefer.

I verified in 5e and SWD that it is working. Obviously I can't test every ruleset, but the language functionality is CoreRPG functionality, so what fixes one should fix most.

Since there was some discussion about about how to fix in code, I like to keep things as simple as possible, so I just changed this:


function onDesktopInit()
if User.isLocal() or User.isHost() then
ChatManager.registerDeliverMessageCallback(insertN pcPortraits)


To this:


function onDesktopInit()
if User.isLocal() or User.isHost() then
ChatManager.unregisterDeliverMessageCallback(Langu ageManager.onChatDeliverMessage);
ChatManager.registerDeliverMessageCallback(insertN pcPortraits)
ChatManager.registerDeliverMessageCallback(Languag eManager.onChatDeliverMessage);


ChatManager.registerDeliverMessageCallback inserts the callback in a table, so they are called in the order they are registered. The NPC portrait callback does not return true, so that it doesn't affect the processing of any callbacks that need to happen after it. So by just unregistering and re-registering the language callback, it just allows the messages to first have the portraits added, and then fall through to the language manager callback.

JoshuaBarbeau
March 29th, 2023, 20:36
I also completely missed the report of issues with the languages. I had my third baby around that time and moved internationally a few months after. Sorry about that, the fix is actually super easy and only took a few minutes. It is up on the Forge or available here (https://github.com/bakermd86/NPCPortraits/releases/tag/v2.2.3) if you prefer.

I verified in 5e and SWD that it is working. Obviously I can't test every ruleset, but the language functionality is CoreRPG functionality, so what fixes one should fix most.

Since there was some discussion about about how to fix in code, I like to keep things as simple as possible, so I just changed this:


function onDesktopInit()
if User.isLocal() or User.isHost() then
ChatManager.registerDeliverMessageCallback(insertN pcPortraits)


To this:


function onDesktopInit()
if User.isLocal() or User.isHost() then
ChatManager.unregisterDeliverMessageCallback(Langu ageManager.onChatDeliverMessage);
ChatManager.registerDeliverMessageCallback(insertN pcPortraits)
ChatManager.registerDeliverMessageCallback(Languag eManager.onChatDeliverMessage);


ChatManager.registerDeliverMessageCallback inserts the callback in a table, so they are called in the order they are registered. The NPC portrait callback does not return true, so that it doesn't affect the processing of any callbacks that need to happen after it. So by just unregistering and re-registering the language callback, it just allows the messages to first have the portraits added, and then fall through to the language manager callback.
JUST IN TIME FOR GAME NIGHT! YOU ABSOLUTE LEGEND!

Running Session 01 of Out of the Abyss tonight, and language barriers is a big part of the first chapter! Thanks a bunch. :)

Congrats on the baby!

MrDDT
December 2nd, 2023, 05:12
Thank you for this EXT, I wanted to report after the last update I'm getting this error from this EXT loaded.

[ERROR] Handler error: [string "NPC_Portraits:scripts/npc_manager.lua"]:18: attempt to call field 'isLocal' (a nil value)

Jiminimonka
December 2nd, 2023, 17:08
Looks like all isLocal stuff got removed and you have to use Session.IsHost drop thru instead.

I noticed using this that some NPCs tokens work and some do not.

sirnoobsauce
December 2nd, 2023, 20:33
Thank you for this EXT, I wanted to report after the last update I'm getting this error from this EXT loaded.

[ERROR] Handler error: [string "NPC_Portraits:scripts/npc_manager.lua"]:18: attempt to call field 'isLocal' (a nil value)

Thanks for letting me know, it should be fixed now.

MrDDT
December 2nd, 2023, 21:55
Thanks for letting me know, it should be fixed now.

Thank you so much, I can confirm it's working and fixed up.

MrDDT
December 2nd, 2023, 22:11
I noticed a new option (at least I've never seen it) called
Override Option Position. It has 1 to 10 options. What is this for?

sirnoobsauce
December 3rd, 2023, 15:07
I noticed a new option (at least I've never seen it) called
Override Option Position. It has 1 to 10 options. What is this for?

Oh yeah, that is is something I added a while ago actually, but due to the Forge sometimes being slow, ended up never getting set to the live version (whoops). I added that because a couple of people told me about issues when using webp tokens for NPCs. If you have an NPC using an animated webp/webm token, FG supports those animations in maps now, but the portrait system can't use them for chat images.

So instead, I added an override option to the right click context menu on NPC sheets (https://github.com/bakermd86/NPCPortraits/blob/master/doc/npc_override.gif).

But because this extension is intended to be ruleset agnostic, I added the option to make sure that the menu option doesn't conflict with other right-click menu items. If the ruleset has some important right-click menu item that the NPC token override conflicts with, the option will allow users to move the option around to an empty slot.

MrDDT
December 3rd, 2023, 16:51
Oh yeah, that is is something I added a while ago actually, but due to the Forge sometimes being slow, ended up never getting set to the live version (whoops). I added that because a couple of people told me about issues when using webp tokens for NPCs. If you have an NPC using an animated webp/webm token, FG supports those animations in maps now, but the portrait system can't use them for chat images.

So instead, I added an override option to the right click context menu on NPC sheets (https://github.com/bakermd86/NPCPortraits/blob/master/doc/npc_override.gif).

But because this extension is intended to be ruleset agnostic, I added the option to make sure that the menu option doesn't conflict with other right-click menu items. If the ruleset has some important right-click menu item that the NPC token override conflicts with, the option will allow users to move the option around to an empty slot.

Gotcha.

Setting the token for chat on an NPC, does this need to be done once per campaign? or can you set this for the NPC itself when making the NPC? Lets say then sticking it in a module.

nephranka
January 24th, 2024, 12:49
Question: Does this work with Linux OS? I get PC portraits but not NPCs. I don't see a dummy npc portrait in the folder. So the creation of the dummy portraits seems not to be working for me?

Jiminimonka
January 24th, 2024, 14:47
Question: Does this work with Linux OS? I get PC portraits but not NPCs. I don't see a dummy npc portrait in the folder. So the creation of the dummy portraits seems not to be working for me?

The operating system is (hopefully, Moon Wizard) irrelevant.

If this isn't working it must be a bug, I will have a look this evening, I think I already have this extension.

nephranka
January 24th, 2024, 15:03
The operating system is (hopefully, Moon Wizard) irrelevant.

If this isn't working it must be a bug, I will have a look this evening, I think I already have this extension.

I saw in post #15 there was some discussion on OS so I thought that might be my issue since Windows is the default for most.

Jiminimonka
January 25th, 2024, 14:41
I saw in post #15 there was some discussion on OS so I thought that might be my issue since Windows is the default for most.

I will try to remember to test at the weekend.

nephranka
January 25th, 2024, 14:45
I will try to remember to test at the weekend.

Thanks!

Atreides Ghola
March 1st, 2024, 02:37
See below.

Atreides Ghola
March 1st, 2024, 12:17
Hey again,

So, this extension doesn't appear to be working in any ruleset.

Previously (as early as last week), it was working for me in D&D 5e, Pathfinder 2e, and Dune. Currently, even in clean campaigns with no other extensions enabled, it doesn't show NPC portraits, only PC portraits.

Mazzar
March 12th, 2024, 03:47
Hey again,

So, this extension doesn't appear to be working in any ruleset.

Previously (as early as last week), it was working for me in D&D 5e, Pathfinder 2e, and Dune. Currently, even in clean campaigns with no other extensions enabled, it doesn't show NPC portraits, only PC portraits.

@sirnoobsauce It seems this is not working in the new version of FGU

rigerco
March 19th, 2024, 15:47
Same here in Savage Worlds. Love this extension, hope it gets an update.

Sayis
March 28th, 2024, 20:45
Any updates on this one?

Ulric
March 31st, 2024, 14:10
It's not working in Starfinder.

rigerco
March 31st, 2024, 14:16
My opinion is that this creator has abandoned his extensions. They haven't been updated since last year and he hasn't posted anywhere, either. I threw this in as suggestion for SW to implement as part of the core software.