PDA

View Full Version : Need help formating dice rolls



Blacky
March 15th, 2013, 19:43
Newbie alert

I'm using a ruleset, which has this code :



local Total = entry.diemodifier;
for k,De in ipairs(entry.dice) do
if De.result then
Total = Total + De.result;
end
end

local Text = entry.text .. ListeDes;
entry.text = Text .. " [Total: " .. Total .. "]";

deliverMessage(entry);

return true;

Which gives a result like this for the last “Total” value: https://temp.dorem.info/screenshots/bscr-4wd3.png (for a roll with modifier).

I would like to be able to control this, and format it the way I like. And probably exploding it, to be able to insert strings between things.

But for the life of me, I can't find anything on this. I'm guessing this is generated by entry.diemodifier, but I can't find anything on it. Neither is Google.

Anyone to help, please, pretty pretty please?

JohnD
March 15th, 2013, 20:48
I have no idea but I wonder if knowing which ruleset you're using would help someone who does have an idea.

Ikael
March 15th, 2013, 20:54
At the moment there is not much possibilities on deciding how you would like your die results look like. It really depends on what you want to do. The base structure (that you must approciate) is that you can have ICON, SENDER's name TEXT and DIE ROLL RESULTS+MODIFIERS, and optionally TOTAL/HALF/NONE sum of the die roll+modifier. This page contains all details about how you can alter your chat message: https://www.fantasygrounds.com/refdoc/Comm.xcp

Please feel free to state what you would like to achieve and we can help you more :)

Blacky
March 15th, 2013, 22:40
Thanks, I'll check the comm package.

Well right now I'm exploring what can be done. But from the top of my head:

Right now, using a Warhammer v2 ruleset, double clicking on a skill gives with a 10 malus you:


PlayerName: Search Test (36%) = [1d100] [Total: 61] 77+10

The red 77 being a dice icon, and the 51+10 being (as show in my screenshot above) in a white rounded box.


I would like to get something like :


:pirate: PlayerName: Search test critically failed (4 degrees) with a 61+10 over 36%.
The smiley being the Player Portrait.

No more white box that attract all the attention to something we don't care about, bold the important thing in that output, and some basic math and if or case conditions to check for degrees of success.

This being called from a script called from the charactersheet, and not the /die command or the dice dropping with the mouse. Maybe it's easier to customize this than all dice rollings.

Moon Wizard
March 15th, 2013, 23:23
You should be able to query the roll "type", then process the dice results manually to create a text only message as opposed to a message with dice. You just need to "return true" in the onDiceLanded handler if you don't want the default behavior.

The 3.5E and 4E rulesets both do this, albeit the framework is very complex since it allows registration of roll type captures.

Regards,
JPG

Blacky
March 15th, 2013, 23:55
Oh ok! So, I expand the script currently called when the charsheet is clicked to manually do what I need, then export this to chat while reutnr true; the appropriate handler?

Seems much more simple. Well, seems like less a colossal complex task I have no idea where to begin ;) At least now, I know where to begin my investigation.

Thanks a lot.

S Ferguson
March 16th, 2013, 18:48
Oh ok! So, I expand the script currently called when the charsheet is clicked to manually do what I need, then export this to chat while reutnr true; the appropriate handler?

Seems much more simple. Well, seems like less a colossal complex task I have no idea where to begin ;) At least now, I know where to begin my investigation.

Thanks a lot.

Hey, don't sweat. They all look colossal in the begining. ;)

Blacky
March 17th, 2013, 06:35
Hey, don't sweat. They all look colossal in the begining. ;)
Thanks, indeed the beginnings are hard…

Right now I'm trying to figure out how to do that:


You should be able to query the roll "type"

Going through the refdoc, Google, to no avail.

Moon Wizard
March 17th, 2013, 07:43
The onDiceLanded event passes a dragdata object as a parameter.
https://www.fantasygrounds.com/refdoc/chatwindow.xcp#onDiceLanded

The dragdata object "type" can be queried using the dragdata.getType or dragdata.isType functions.
https://www.fantasygrounds.com/refdoc/dragdata.xcp#getType

Regards,
JPG

Blacky
March 17th, 2013, 08:22
Any dice roll, wherever it's coming from, is a dragdata? Oh, I think things are clearer now…

Ok thanks a lot!!

S Ferguson
March 17th, 2013, 16:23
Any dice roll, wherever it's coming from, is a dragdata? Oh, I think things are clearer now…

Ok thanks a lot!!

Yep. They need the drag data to determine where they fall on the desktop; be it the chatbox (public die rolls) or dicetower (private rolls) or anywhere (non-critical die rolls that I personally use as official GM-Only rolls).

Cheers,
SF

Moon Wizard
March 17th, 2013, 18:34
One note, the dragdata object is used to access the "dragging" object of the cursor for any object type (strings, numbers, dice, etc.).

When the onDiceLanded event is fired, the dragdata object that triggered the dice is provided, whether it was via user drag or via the Comm.throwDice function.

The one difference between the dragdata object while just dragging and during the onDiceLanded event is that the getDice() function returns a simple table ({ "d6", "d6" }) while just dragging and returns a die plus results table ( { { type = "d6", result = 4 }, { type = "d6", result = 3 } } ) during the onDiceLanded event.

Regards,
JPG