PDA

View Full Version : Die Usage.



drahkar
November 21st, 2009, 01:13
Has anyone made use of diefield and diecontrol that wouldn't mind showing the means they had used them?

I'm working on putting together a sequence that when generating a character sheet you can have the results of a die roll automatically dropped into the field you are working on. But I need a better understanding on how the program uses the results of a die roll.

drahkar
November 21st, 2009, 04:34
Has any thought gone into having the function onDiceLanded added as an option to Window Instance so that we could directly associate a roll to things like rolling a stat for a character sheet without having to drag the number over from the chat window?

Valarian
November 21st, 2009, 11:06
Why not just use onDoubleClick to roll the stat/skill?
https://www.fantasygrounds.com/forums/showthread.php?t=6015

You should, I think, be able to take the existing double-click code and make another function to pass in a table of dice to roll. Pass in the dieField content and modifier to the chatManager.throw command. The option would be there to drag the dice from the dieField, or to double-click to roll the dice. It's something I've considered for weapon damage on some of my rulesets. If you get stuck, let me know and I'll have a look.

Moon Wizard
November 21st, 2009, 11:36
As Valarian said. Also, you can then capture the results of the die throw and place them in the correct field. You can use the customdata object or the string data object to pass parameters about which character or field that the dice roll is associated to.

Cheers,
JPG

Valarian
November 25th, 2009, 22:51
For anyone wondering how this is done ....

In ChatManager.lua place the following function


function diceRoll(dice, bonus, name)
if control then
control.throwDice("dice", dice, bonus, name);
end
end


In the script section of the diefield, you call the ChatManager function in a similar way to the call for double-click die rolling.


function onDoubleClick(x,y)
local dice = window.damagedice.getDice();
local bonus = window.damagebonus.getValue();
local name = window.name.getValue() .. " damage";
ChatManager.diceRoll(dice, bonus, name);
return true;
end

drahkar
November 26th, 2009, 15:41
Very nice. I'll have to look that over and consider ways of incorporating it. Thanks for the advice and thoughts on the topic!