You can replace the rolled dice list inside a die handler, intercepting the results and replacing them with a new die list for output to the chat message. This is what I do for Yggdrasill. Replace the rolled list (of 3 or 4 dice) with the sorted list (of 2 or 1). Inside the die handler, I choose the highest results to display to the chat log.
The issue I'm currently struggling with is the modifier stack. It seems to work for dragging the dice but not for the double-click (where I use Comm.throwDice instead of draginfo). I can't seem to create a draginfo object for the double-click function to use, and the separated throwDice function seems to clear and overwrite the modifier stack.Code:-- This file is part of the Fantasy Grounds Open Foundation Ruleset project.
-- For the latest information, see https://www.fantasygrounds.com/
--
-- Copyright 2008 SmiteWorks Ltd.
--
-- This file is provided under the Open Game License version 1.0a
-- Refer to the license.html file for the full license text
--
-- All producers of work derived from this material are advised to
-- familiarize themselves with the license, and to take special
-- care in providing the definition of Product Identity (as specified
-- by the OGL) in their products.
--
-- All material submitted to the Open Foundation Ruleset project must
-- contain this notice in a manner applicable to the source file type.
function onInit()
ActionsManager.registerResultHandler("skilldice", handleSkillDice);
end
function handleSkillDice(rSource, rTarget, rRoll)
local reroll = false;
local total = {};
local firstResult = 0;
local secondResult = 0;
local dicetable = rRoll.aDice;
if dicetable then
for n = 1, table.maxn(dicetable) do
if dicetable[n].type == "d10" then
if firstResult > 0 and dicetable[n].result > secondResult then
secondResult = dicetable[n].result;
total[2] = dicetable[n];
elseif dicetable[n].result > firstResult then
firstResult = dicetable[n].result;
total[1] = dicetable[n];
end
end
end
end
if firstResult == 10 or secondResult == 10 then
repeat
local reroll = false;
local dieRoll = math.random(1,10);
local explode = {};
explode.type = "d10";
explode.result = dieRoll;
table.insert(total, explode);
-- Purely for effect - roll a d10
local dice = {};
table.insert(dice, "d10");
Comm.throwDice("explode", dice, 0, "explode");
if dieRoll == 10 then
reroll = true;
end
until not reroll
end
local rMessage = ChatManager.createBaseMessage(rSource, rRoll.sUser);
rMessage.type = rRoll.sType;
rMessage.text = rMessage.text .. rRoll.sDesc;
rMessage.dice = total;
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 total and #(total) > 0 then
rMessage.dicedisplay = 1;
end
Comm.deliverChatMessage(rMessage);
ModifierStack.reset();
return true;
end

