PDA

View Full Version : Rolling multiple dice types at once?



Lundgren
February 6th, 2014, 10:45
I have just started to poke under the hood of FG and trying to get a grasp of what is possible or not.

From a few of the old post, I understand it as it would be possible to make, for example, a 2D12+D8+2D4 in one roll. However, I could not find anything on how to actually do it. But before spending to much time trying to figure it out on my own, I thought I would try something new and actually ask :)

A code snipped on how to do this would be appreciated. Lacking that, some general ideas on how to achieve it.

Trenloe
February 6th, 2014, 11:16
The dice that will be rolled are stored in a LUA table (similar to an array) - with the "type" being the die, e.g. d4, d6, etc.. You have to add each die to the table separately, so the example you give above would be d12, d12, d8, d4, d4.

In the CoreRPG ruleset, campaign\scripts\table_main onDrop function gives an example of putting individual dice in a table (aDice) and then rolling (based off dice in a drag/drop process ) with "TableManager.performRoll(nil, nil, nodeWin, nDropColumn, true, aDice, nMod);"


-- Get dice and mod
local aDice = {};
for _,v in ipairs(aDropDiceList) do
table.insert(aDice, v.type);
end

Lundgren
February 6th, 2014, 12:20
Thanks :) That's what I was looking for.

Time to do some tests and see what happens.

Valarian
February 6th, 2014, 12:31
This is a snippet from my The One Ring code for rolling dice on a double-click. The function is called from the skill, giving the number of "skill" dice (d6). A d12 is added to the roll for the Feat die.



function skillDiceCheck(number, bonus, name)
if ChatManager.control then
local dice = {};
table.insert(dice, "d12");
for i = 1, number, 1 do
table.insert(dice, "d6");
end
ChatManager.control.throwDice("skilldice", dice, bonus, name);
end
end

Trenloe
February 6th, 2014, 13:28
This is a snippet from my The One Ring code for rolling dice on a double-click. The function is called from the skill, giving the number of "skill" dice (d6). A d12 is added to the roll for the Feat die.



function skillDiceCheck(number, bonus, name)
if ChatManager.control then
local dice = {};
table.insert(dice, "d12");
for i = 1, number, 1 do
table.insert(dice, "d6");
end
ChatManager.control.throwDice("skilldice", dice, bonus, name);
end
end

This explains the process very well.

Just as an FYI if anyone tries to use this code: Chatmanager.control.throwDice won't work with the FG 3.0 CoreRPG based rulesets. Use Comm.throwDice instead: https://www.fantasygrounds.com/refdoc/Comm.xcp#throwDice

Lundgren
February 6th, 2014, 13:48
This is a snippet from my The One Ring code for rolling dice on a double-click. The function is called from the skill, giving the number of "skill" dice (d6). A d12 is added to the roll for the Feat die.Thanks :) As I'm not familiar with the rules in One Ring, I guess it also passes it through some custom code to handle whatever the Fate Die do?


Just as an FYI if anyone tries to use this code: Chatmanager.control.throwDice won't work with the FG 3.0 CoreRPG based rulesets. Use Comm.throwDice instead: https://www.fantasygrounds.com/refdoc/Comm.xcp#throwDiceAh, good to know :)

Valarian
February 6th, 2014, 17:54
https://www.fantasygrounds.com/refdoc/Comm.xcp#throwDice[/url]
Good to know for when I try converting the extension to CoreRPG.

Valarian
February 6th, 2014, 17:57
As I'm not familiar with the rules in One Ring, I guess it also passes it through some custom code to handle whatever the Fate Die do
Yes, there are dice handlers for a normal roll, and one where the character is weary.

damned
February 8th, 2014, 11:10
am I missing something or cant we just type: /die 2D12+D8+2D4

Valarian
February 8th, 2014, 13:22
You can. Depends what you want to do with the dice. If you want to do something different to just totalling, you need a die handler and that means changing the die label/type rolled (e.g. skilldice).