View Full Version : Can chatlog log actual dice rolled?
Tarostar
January 24th, 2010, 11:39
Ok, I'm very happy with the current state of my rulesystem and the only thing left that I can't tame is the chatlog.
When I roll several dice it displays the dice just find so 3D4 is displayed as the actual rolled results, e.g. 2, 3, 3. This is what I want as the dice are not added together, but instead I simply use the highest result.
However, when I open the chatlog.html it has stored it as [3d4 = 8].
Can this be changed? Any idea where?
Also (but not as important) when rolling dice the dice table gets sent off to throwDice. Is it possible to make the chat window display the highest rolled result?
Thanks
Foen
January 24th, 2010, 22:40
You should perhaps explore the onDiceLanded event in chatwindow (https://www.fantasygrounds.com/refdoc/chatwindow.xcp), that might help.
Foen
Tarostar
January 25th, 2010, 20:31
You should perhaps explore the onDiceLanded event in chatwindow (https://www.fantasygrounds.com/refdoc/chatwindow.xcp), that might help.Foen
Thanks Foen.
I can do a bit of manipulation there but there doesn't seem to be any control over the chat history. The best I've been able to accomplish is to override the roll and do my own formatting using deliverMessage, but it still records the actual die rolls as f.eks [2d4 = 7]. At least I can insert the best die result as part of the text message, but it's not how I'd prefer it as it clutters up the chat output a bit. Ideally I would want the chat history to log the actual rolls so in the above example 3 and 4 or even better [2d4 = 3, 4].
Here is what I did (I don'r really need the modifier, but keeping it for now...):
local entry = {};
entry.font = "systemfont";
entry.text = draginfo.getDescription();
entry.dice = draginfo.getDieList();
applyModifierStackToRoll(draginfo);
entry.diemodifier = draginfo.getNumberData();
-- never hide rolls (for secret rolls use your desktop as it isn't for players anyway)
entry.dicesecret = false;
-- highest roll
local bestresult = 0;
for k, d in ipairs(entry.dice) do
if d.result > bestresult then
bestresult = d.result;
end
end
entry.text = "[" .. bestresult .. "] " .. entry.text;
if User.isHost() then
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end
if User.isHost() then
entry.icon = "portrait_gm_token";
else
entry.icon = "portrait_" .. User.getCurrentIdentity() .. "_miniportrait";
end
-- Deliver the chat entry
deliverMessage(entry);
return true;
Tarostar
January 25th, 2010, 20:36
Alternatively I'm toying with the idea of instead adding the line
entry.diemodifier = bestresult * -1;
At least this way I get the highest roll at the end with a dash (actually a minus, but it looks the same...)
With that I get a chat history output like [3d10-8 = 7] which is pretty close to what I want. I can always remove the = 7 bit with a html log parser, even if not ideal.
Foen
January 25th, 2010, 21:19
You can use onDiceLanded to examine the individual dice and then write your own custom message to the chat box, preventing the FG engine from posting its default message.
The details are too complex to cover here, but the Base Ruleset for example replaces a (d100,d10) combination with a single result in the range 01-100. The process is roughly:
Intercept the results in onDiceLanded (look in chat_chat.lua) and process the individual die results;
Create your replacement message and send to the chat box (look at deliverDieResults in the same file of the Base Ruleset); and then
Return a value of 'true' from onDiceLanded, as this prevents FG from delivering its own die roll results.
Hope that helps,
Foen
Tarostar
January 26th, 2010, 12:39
You can use onDiceLanded to examine the individual dice and then write your own custom message to the chat box, preventing the FG engine from posting its default message.
Yes, this is understood and what I do in my example above. However, I like the dice showing up as... dice, so I don't want to replace the dice graphics with just boring numbers. Any idea if there is a way to show the dice results as dice graphics, but still get the chat history to log them as individual dice results?
Foen
January 26th, 2010, 19:27
You can get the dice showing up in your own chatbox messages, just add a dielist to the message as follows (example is for 3d6, with die results of '4', '5' and '6'):
local dielist =
{ {type="d6",result=6},
{type="d6",result=5},
{type="d6",result=4}
};
message.dice = dielist;
message.text = "Some dice";
message.font = "systemfont";
deliverMessage(message);
Hope that helps,
Foen
Tarostar
January 26th, 2010, 22:40
You can get the dice showing up in your own chatbox messages, just add a dielist to the message...
Thanks for trying Foen, but I probably didn't explain properly. What you suggest is pretty much what my code does as well and it shows the die results correctly in the chat. The problem is when you open up the chat history, that is the chatlog.html. In there the result is compacted into "Some dice [3d6 = 15]" for some reason. That is what I want to change so I have a record of what was rolled during play, but I don't wont to clutter up the chat by reprinting the die rolls as numbers.
If it isn't possible to log the die roll results without adding them together is it possible to write to the chatlog.html without showing it in the chat window during play?
Foen
January 26th, 2010, 22:47
Gotcha! I think you are stretching my FG-fu a bit far :(
The best I can suggest is just what you have already considered: add some narrative to the text element of the message which says something like [3d6, best=6] which will then show up in the chat history and in chatlog.html.
Foen
tdewitt274
January 27th, 2010, 03:23
Just tossing this out there, but couldn't you throw the die results as a GM /whisper?
This way it doesn't clog up the Player's view, the GM is on their own...
Tarostar
January 27th, 2010, 17:17
Just tossing this out there, but couldn't you throw the die results as a GM /whisper?
This way it doesn't clog up the Player's view, the GM is on their own...
Interesting thought. I'll look into it, thanks!
Tarostar
January 27th, 2010, 18:06
SUCCESS! :D
I've set it up so the players still only see the die graphics as usual, but the GM also gets a list of die results rolled as well as the highest result.
if User.isHost() then
addMessage(gmMessage);
else
ChatManager.deliverMessage(gmMessage, "");
end
Thanks for your suggestions guys!
Griogre
January 27th, 2010, 23:36
I'm not sure whispering the GM is a good idea - you already get two or three times as much traffic on the chat window. GMs would start ignoring whispers which is not really a good thing. Let us know how this works out.
Tarostar
January 28th, 2010, 11:34
I'm not sure whispering the GM is a good idea - you already get two or three times as much traffic on the chat window. GMs would start ignoring whispers which is not really a good thing. Let us know how this works out.
That code does not send a whisper. In my case it simply adds a second line directly under the roll result, without a sender, showing f.ex "roll: 4, 6, 2. Highest 6." in a small font. But only the GM sees it. I could not show the die roll graphics for only the GM if I wanted to keep it to one line, but as I said I like the dice graphics. If it becomes too hectic I might try that. The nice thing about this is that the GM instantly sees the highest result.
However, it would have been better if the graphics were just logged as the dice results in the chat log but I don't think it is possible to change this with rulesets.
tdewitt274
January 28th, 2010, 15:23
That code does not send a whisper. In my case it simply adds a second line directly under the roll result, without a sender, showing f.ex "roll: 4, 6, 2. Highest 6." in a small font. But only the GM sees it. I could not show the die roll graphics for only the GM if I wanted to keep it to one line, but as I said I like the dice graphics. If it becomes too hectic I might try that. The nice thing about this is that the GM instantly sees the highest result.
However, it would have been better if the graphics were just logged as the dice results in the chat log but I don't think it is possible to change this with rulesets.
I don't know if this would be an issue or not, but is the reference fast enough to catch two different rollers at the same time or someone talking over someone rolling? May not be a problem, but I would add who made the roll to the text as well.
Tarostar
January 28th, 2010, 16:45
I don't know if this would be an issue or not, but is the reference fast enough to catch two different rollers at the same time or someone talking over someone rolling? May not be a problem, but I would add who made the roll to the text as well.
Doubt it as it is very fast and has not been a problem in testing so far, but it is early days so we'll see. I skip the rollers name on purpose or it would look like someone is saying something which could be annoying. Without sender name the result looks very neat and follows naturally from the roll. If I decide to get rid of the dice graphics for the GM I'll of course add sender's name. Hope to expose it to some proper playtesting next week and all shall be revealed.
Bidmaron
February 5th, 2010, 01:02
How'd it go?
Tarostar
February 10th, 2010, 18:25
Sorry, forgot to update here but it worked well with four people + GM (everyone knows GMs are not people, right...). There was a lot of dice rolling, sometimes simultaneous, as people were testing the dice and it always appeared inline right below. It does eat up a bit of chat-window real estate, but not so much as to be an issue. However, I have quite a bit of screen real-estate and would have appreciated a resizeable chat window to take advantage of that...
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.