PDA

View Full Version : How to include portraits in chat.



joshuha
June 12th, 2007, 00:46
In order not to threadjack another thread, it was asked how to include the player portait in the chat.

This involves a simple modification to the chat_entry.lua file in your [ruleset]/scripts folder. If you want to do this to the default ruleset you will need to create a cusom version by extracting the d20.pak file and placings in the ruleset directory and rename it to something like myd20.

Replace this function:


function onDeliverMessage(messagedata, mode)
if User.isHost() then
gmid, isgm = GmIdentityManager.getCurrent();

if messagedata.hasdice then
messagedata.sender = gmid;
messagedata.font = "systemfont";
elseif mode == "chat" then
messagedata.sender = gmid;

if isgm then
messagedata.font = "dmfont";
else
messagedata.font = "npcchatfont";
end
elseif mode == "story" then
messagedata.sender = "";
messagedata.font = "narratorfont";
elseif mode == "emote" then
messagedata.text = gmid .. " " .. messagedata.text;
messagedata.sender = "";
messagedata.font = "emotefont";
end
end

return messagedata;
end


with this:


function onDeliverMessage(messagedata, mode)
if User.isHost() then
gmid, isgm = GmIdentityManager.getCurrent();

if messagedata.hasdice then
messagedata.sender = gmid;
messagedata.font = "systemfont";
elseif mode == "chat" then
messagedata.sender = gmid;

if isgm then
messagedata.font = "dmfont";
else
messagedata.font = "npcchatfont";
end
elseif mode == "story" then
messagedata.sender = "";
messagedata.font = "narratorfont";
elseif mode == "emote" then
messagedata.text = gmid .. " " .. messagedata.text;
messagedata.sender = "";
messagedata.font = "emotefont";
end
else
messagedata.icon = "portrait_" .. User.getCurrentIdentity() .. "_charlist";
end

return messagedata;
end



The only real issue with this is the potraits themselves are rather large. I am trying to think of an automatic way around this but the hacky way would be in your graphic.xml file just create links to already resized portraits for your current characters and modify the above code to call that instead.

Screenshot is a link below (due to size):
https://www.ptolus-fg.com/images/screenshot01.png

joshuha
June 12th, 2007, 03:07
The only real issue with this is the potraits themselves are rather large. I am trying to think of an automatic way around this but the hacky way would be in your graphic.xml file just create links to already resized portraits for your current characters and modify the above code to call that instead.



Found it!
For small portraits change the _charlist to _miniportrait and you are all set. These are 16x16.

For more medium size change the _charlist to _token. These are 30x30.
The _charlist ones I believe are 72x72 including the frame which takes up a lot of the chatbox.

Tokuriku
June 12th, 2007, 09:26
Here we go!
Thanks a lot, It works like a charm :)

TarynWinterblade
June 13th, 2007, 03:12
An idea I was playing around with when I was adding the same thing to my ruleset was making the portraits showing up a user specific setting, so that if you prefer to not have portraits show up in your chat window, you could turn it off.

.. unfortunately, I couldn't find a way to modify the incoming message. OnReceiveMessage only gets a local copy of the message data, and any modifications it does aren't processed.

I did try a version where OnReceiveMessage called AddMessage and then returned true (which stopped the default handling of it), which sorta worked, but it wasn't as clean as it should have been...

Malovech
June 13th, 2007, 03:31
Both of you - awesome, I stole this script as soon as I saw it. Great work thanks!

ldyparadox99
June 18th, 2007, 18:19
Has anyone that used this lost the ability to make /die 1dwhatever command??

Doswelk
June 19th, 2007, 22:14
Has anyone that used this lost the ability to make /die 1dwhatever command??

No seems to work still for me

ldyparadox99
June 20th, 2007, 11:01
Interesting because I added the portraits the other night and lost /die and /w functions. Had to go back and replace it so we could play our session.

I'll have to try again for this coming week.

mossfoot
June 23rd, 2007, 15:21
That's strange. I can't seem to find the files mentioned. Is this for FGI or FGII? Any chance for a bit more of a walk-through? I mean, I looked in the Ruleset section and searched for a chat_entry.lua file everywhere...

ldyparadox99
June 23rd, 2007, 16:19
It's for FG2 and the file you're looking for is actually a .lua file which is a script.

Look in your rule set file for another file named scripts...you'll find it there.

mossfoot
June 23rd, 2007, 23:38
So is there any way for this to work on FGI?

Dachannien
June 24th, 2007, 02:43
No, but it's free to upgrade to FG2.

mossfoot
June 24th, 2007, 10:20
I know, but I have a d6 Starwars ruleset for FGI that I haven't even had a chance to use, and it's not FGII compatible (to the best of my knowledge) :P

Someone really should have made a conversion program for rulesets that's idiot proof (me being the idiot)

Oberoten
June 24th, 2007, 12:10
Well, not that I have high hopes, but I really second that motion.

*and somewhere in Sweden the Village idiot goes missing to quest for a nice shiney new program*

mossfoot
June 24th, 2007, 13:26
Well as frustrating as it is, I am learning a few things ;) I'm going with the Generic ruleset (thanks Toadwart!) for now and modifying it for a Star Wars game with stuff from the Star Wars ruleset for looks and whatnot...

Toadwart
June 24th, 2007, 21:17
Yeah, I'm struggling through an FGI to FG2 conversion process myself at the moment. A lot of it is just search-n-replace to update the node structure but even that is taking a lot longer than I had anticipated.


If you have a heavily modified ruleset I'd recommend starting from scratch and rebuilding it in FG2. After first taking some time to get familiar with the base ruleset.
If your ruleset isn't heavily modified then I'd recommend you start by just converting it over as-is (changing stringcontrol nodes to stringfield nodes, etc) and get it all working before trying to use some of the newer features (like anchoring)
Don't try and do it all at once. Make small changes and test that they work before moving on. FG can be finniky about little things (e.g. a mis-spelled filename, or a mis-spelled class/frame name frame) can cause FG to crash. Going back through a big raft of changes to try and find the cause can be very time consuming.
If you can, find an editor that supports regular expressions as it makes the search-n-replace task easier (I'm using Visual Studio but I guess there must be some free, or at least cheaper, options out there)

mossfoot
June 25th, 2007, 13:02
New questions!

1) Can the script be modified so that the character name doesn't show up? I find it superfluous if we can see the character's picture.

2) Can the script be disabled in the cases of OOC and ACT functions? (in these cases only the name or user name is needed)

joshuha
June 25th, 2007, 14:26
Not without quite a bit of work. Those things involve the default message types and message.sender. You would need to basically stop processing on all messages and rewrite each of those functions. Its doable but would require a bit of work.

And also it does help to have the names in there for logging purposes. The icons don't show up in the log (nor any kind of hidden html code for them) so if you post logs it would be very hard to follow.

mossfoot
June 25th, 2007, 18:26
Perhaps, but perhaps a modification in which only the first three letters show up? Since the character sheet takes the name from your Character Sheet, Having a player named Captain Allisatar Darkstar (for example) really eats up the chatlog. And it doesn't feel right for the character not to have his full name on a sheet, either.

As for OOC and ACT, I should clarify that I meant I don't want the portrait image showing up in OOC and ACT, only for in character talking. Basically I'd want OOC and ACT to be as they are by default, and IC talk to have a portrait attached and just the first three or four letters of their name.

Blue Haven
December 30th, 2007, 15:45
Found it!
For small portraits change the _charlist to _miniportrait and you are all set. These are 16x16.

For more medium size change the _charlist to _token. These are 30x30.
The _charlist ones I believe are 72x72 including the frame which takes up a lot of the chatbox.

Are these values the only ones that we can choose?? because the first one is too small, then the other +/- and the last is too big...one in the middle was the best, like 50x50...

Xorn
March 21st, 2008, 14:08
Are these values the only ones that we can choose?? because the first one is too small, then the other +/- and the last is too big...one in the middle was the best, like 50x50...

If you have resized your default token (when you drag a portrait to the combat tracker or map) to 50x50, then that's what size the _token is going to get you. At least, if I'm understanding that line of code (which looks like it's saying which of the portait masks in the icon folder to use.)

_portrait is used to display the character list.
_token is used to represent them on the map.
_miniportait is used to represent them on the combat tracker.

I've also read it's possible to display a GM portrait next to GM text. Can anyone post how to do that? Can't find it in searches so far.

Xorn
March 22nd, 2008, 04:43
Okay, I've figured out how to have 50x50 tokens from the combat tracker, and 30x30 tokens in the chat window, without extensive work, as well as how to have a GM portrait appear. Here's how I did it--though I'm pretty sure there's a cleaner way to do it:

30x30 chat portraits w/ 50x50 token portraits:
I'll assume you've already made your portraits drag to the map grid at 50x50 (which you just do by resizing a few portrat_xxxxx.png files in the Icon directory. What you need to do is put BACK your old 30x30 portrait_token.png and 26x26 portrait_token_mask.png, but call them portrait_chat.png and portrait_chat_mask.png, respectively. (These go in the Icons folder.)

Now open up graphics.xml and add in these 2 lines with the other portrait definitions:


<icon name="portraitchat_base" file="icons/portrait_chat.png" />
<icon name="portraitchat_mask" file="icons/portrait_chat_mask.png" />

Next open up graphics_portraitsets.xml and add this after the last portrait set:


<portraitset name="chat">
<base>portraitchat_base</base>
<mask>portraitchat_mask</mask>
<createtoken />
</portraitset>

Now you have added the pieces of the 30x30 token, and told FG2 how to refer to it. Last you need to add the line to chat_entry.lua (in \scripts) to tell it when to use it, joshuha covered how to change that just fine, the only difference is you put "_chat" instead of "_token". Viola! 30x30 chat portraits, without messing with the 50x50 map tokens! Note that I wanted to only show portraits for Chat (not emotes or ooc) so I modified the code slightly:


elseif mode == "chat" then
messagedata.icon = "portrait_" .. User.getCurrentIdentity() .. "_chat";
end

That means only chat, /mood, or die rolls will have a portrait next to them.

Adding a GM portrait to GM chat/die rolls
First, make a .png token. Make it the same as the other chat portraits (so mine is a 30x30 token of a meteor, some of you will get that joke), and save it in \icons. I called my portrait_gm_token.png. Do the same if you have no idea what you're doing.

In graphics.xml, add this line in with the other portrait definitions:


<icon name="portrait_gm_token" file="icons/portrait_gm_token.png" />

Now in the chat_entry.lua section, find the part that looks like this:


if messagedata.hasdice then
messagedata.sender = gmid;
messagedata.font = "systemfont";
elseif mode == "chat" then
messagedata.sender = gmid;

And make it look like this (you're just adding in the same line in two spots):


if messagedata.hasdice then
messagedata.icon = "portrait_gm_token";
messagedata.sender = gmid;
messagedata.font = "systemfont";
elseif mode == "chat" then
messagedata.icon = "portrait_gm_token";
messagedata.sender = gmid;

You can put this line in different places, which will dictate when a portrait displays, but I don't want it to show all the time, only when I do chat or reveal a die roll. Same with the players, I only want to see their portrait when they talk or roll dice.

I was trying to make it show when they emote, but the snag I'm hitting is that mode == "emote" will catch Ctrl+Shift+Enter, but will NOT catch /em when a player types it. (It will catch it when a GM does /em, but I think that's because "what to do" is defined right there.) If someone can help me figure that part out, I'd appreciate it, but I'm still very happy with:

https://www.eugee.net/images/fg/portrait.chat2.jpg

Blue Haven
March 22nd, 2008, 15:49
Wonderful :) thanks very much for this :D

Xorn
March 23rd, 2008, 12:52
My pleasure, and if I can do it, anyone can, I stumbled through this!

For my brother's SWSE, his GM token is the Death Star. LOL

cbradshaw007
June 23rd, 2008, 19:52
I have to ask if anyone knows where to change the GM title? After reading this thread and making the changes in my SWSE ruleset, I added a GM token of George Lucas and want GM replaced by "The Maker"

joshuha
June 23rd, 2008, 19:54
I believe its /gmid "The Maker"

cbradshaw007
June 23rd, 2008, 20:02
I was thinking more on the line of hard coded in the background. I just havent found where it is stated yet.

Foen
June 24th, 2008, 06:38
Yep, its in the gmidentitymanager.lua script, here's the code:


function registerIdentityList(list)
-- Store a reference to the list window
identitylist = list;
local gmidname = CampaignRegistry.gmidentity or "The Maker";
addIdentity(gmidname, true);
end


Hope that helps,

Foen

cbradshaw007
June 24th, 2008, 16:16
Thanks Foen

Xorn
September 7th, 2008, 02:21
So... 4E_JPG has stabilized enough that I decided to put The Box and chat portraits back into my ruleset. Now I had no trouble with either of those, but I'm not able to get the GM Portrait to show up--which I'm guessing is because 4E_JPG does some funky stuff with the chat from the Host (adding the name of the NPC generating a roll and such).

I added an icon called "portrait_dm.png" to my \icons folder.
Then I defined it in graphics.xml, defining it as "portrait_dm".
Then I added the "messagedata.icon =" in chat_entry.lua, matching the defined name above.

Nothing. Is it because 4E_JPG handles Host chat differently?

EDIT - Oops, I had the wrong file name listed for the DM portrait. It works great!

DM/Player Perspectives (https://www.eugee.net/fg/modsadded.jpg)

Polyhedral
September 7th, 2008, 16:56
So... 4E_JPG has stabilized enough that I decided to put The Box and chat portraits back into my ruleset. Now I had no trouble with either of those, but I'm not able to get the GM Portrait to show up--which I'm guessing is because 4E_JPG does some funky stuff with the chat from the Host (adding the name of the NPC generating a roll and such).

I added an icon called "portrait_dm.png" to my \icons folder.
Then I defined it in graphics.xml, defining it as "portrait_dm".
Then I added the "messagedata.icon =" in chat_entry.lua, matching the defined name above.

Nothing. Is it because 4E_JPG handles Host chat differently?

EDIT - Oops, I had the wrong file name listed for the DM portrait. It works great!

DM/Player Perspectives (https://www.eugee.net/fg/modsadded.jpg)

Very Nifty!

BBPlainwell
September 24th, 2008, 00:40
I am working with the 4e ruleset and while I can get the chat for both players and gm to show the correct sized picture, the die rolls just show the names. Is there something else I have to change to get the die rolls to show portraits?

Tenian
September 24th, 2008, 01:19
Yes there is, the 4E_JPG does a lot of stuff when dice land so you'd need to change some of those functions. However 1.1.2 (the latest) has Portrait Chat already included. It's on the options screen as "Show portraits in chat"

BBPlainwell
September 24th, 2008, 01:46
Yes there is, the 4E_JPG does a lot of stuff when dice land so you'd need to change some of those functions. However 1.1.2 (the latest) has Portrait Chat already included. It's on the options screen as "Show portraits in chat"

That fixed the GM side but the players die rolls still just show the name and not the portrait.

Tenian
September 24th, 2008, 02:18
Odd..it seems to work for me both as a player and GM. You should probably post about it over on FUM

BBPlainwell
September 24th, 2008, 15:21
Odd..it seems to work for me both as a player and GM. You should probably post about it over on FUM

I made a backup of all my 4e stuff, deleted my 4e ruleset and installed the latest one. Then copied everything back but the graphics and chat.lua and it works fine now.