PDA

View Full Version : Displaying Character Portraits from Comm.deliverChatMessage(msg)



damned
June 26th, 2016, 07:58
Is there a way to display the portrait of the character when using the Comm.deliverChatMessage? At the moment Im displaying an Icon that has been defined as button_link but I want to display the characters portrait…

local sRollName = nodeWin.getChild("name").getValue();
local msg = {font = "msgfont", icon = "button_link" };
msg.text = rActor.sName .. " uses " .. sRollName;
Comm.deliverChatMessage(msg);

Zacchaeus
June 26th, 2016, 08:54
I think you need a Moon Wizard :)

Andraax
June 26th, 2016, 15:04
Try something like:

local sCurrentId = User.getCurrentIdentity();
if sCurrentId then
sIcon = "portrait_" .. sCurrentId .. "_chat";
end

Andraax
June 26th, 2016, 19:22
Here's what I would do (rRoll has your die roll info in it, gmIDName is the ID currently used by the GM, if speaking as someone else; will use rActor.sName if a user name is in there):


-- Build the basic message to deliver
local rMessage = ChatManager.createBaseMessage(rActor.sName, gmIDName);
rMessage.type = rRoll.sType;
rMessage.text = rMessage.text .. rActor.sName .. " uses " .. sRollName;
rMessage.dice = rRoll.aDice;
rMessage.diemodifier = rRoll.nMod;

-- Check to see if this roll should be secret (GM or dice tower tag)
if rRoll.bSecret then
rMessage.secret = true;
if rRoll.bTower then
rMessage.icon = "dicetower_icon";
end
elseif User.isHost() and OptionsManager.isOption("REVL", "off") then
rMessage.secret = true;
end

-- Show total if option enabled
if OptionsManager.isOption("TOTL", "on") and rRoll.aDice and #(rRoll.aDice) > 0 then
rMessage.dicedisplay = 1;
end

This should use the user portrait, or the GM icon, or the dice tower icon, whichever is correct (but only if the "use portraits" setting is on).

damned
June 27th, 2016, 00:03
Try something like:

local sCurrentId = User.getCurrentIdentity();
if sCurrentId then
sIcon = "portrait_" .. sCurrentId .. "_chat";
end

Thank you Andraax - I have this working now.


Here's what I would do (rRoll has your die roll info in it, gmIDName is the ID currently used by the GM, if speaking as someone else; will use rActor.sName if a user name is in there):


-- Build the basic message to deliver
local rMessage = ChatManager.createBaseMessage(rActor.sName, gmIDName);
rMessage.type = rRoll.sType;
rMessage.text = rMessage.text .. rActor.sName .. " uses " .. sRollName;
rMessage.dice = rRoll.aDice;
rMessage.diemodifier = rRoll.nMod;

-- Check to see if this roll should be secret (GM or dice tower tag)
if rRoll.bSecret then
rMessage.secret = true;
if rRoll.bTower then
rMessage.icon = "dicetower_icon";
end
elseif User.isHost() and OptionsManager.isOption("REVL", "off") then
rMessage.secret = true;
end

-- Show total if option enabled
if OptionsManager.isOption("TOTL", "on") and rRoll.aDice and #(rRoll.aDice) > 0 then
rMessage.dicedisplay = 1;
end

This should use the user portrait, or the GM icon, or the dice tower icon, whichever is correct (but only if the "use portraits" setting is on).

I will have a look at this method also.
Appreciate your help :)