PDA

View Full Version : Accessing the Builtin Magics of the dragdata Object



Minty23185Fresh
January 13th, 2021, 18:04
I am working through the settings of a dragdata object for a Skill die dragged into the Dice Tower.
I have come across some behind the scenes (builtin?) functionality that I need help with.

Here is a code snippet from ...\rulesets\CoreRPG\scripts\manager_actions.lua


function encodeRollForDrag(draginfo, i, vRoll)
for k,v in pairs(vRoll) do
if k == "sType" then
draginfo.setSlotType(v);
elseif k == "sDesc" then
draginfo.setStringData(v);
elseif k == "aDice" then
draginfo.setDieList(v);
elseif k == "nMod" then
draginfo.setNumberData(v);
elseif type(k) ~= "table" then
...


The value of the argument, "v", in the setDieList(v) function call highlighted above is "{ #1 = s'd20' }".

Yet, if I do a draginfo.getDieList() the value that is returned is " { #1 = { s'type' = s'd20' }, s'expr' = s'd20' }".

Put one thing in the box, if you pull it back out of the box it has morphed into something completely different. Is there a way for me to access these "magics"?

Moon Wizard
January 15th, 2021, 23:28
No, there is no mechanism for that. The return value will always be the same in FGU for consistency (it was not in FGC, and varied depending on the what phase the roll was in). The input values can be in the old style or the new style for backward compatibility.

Basically, the FGU system treats all "dice" values as dice expressions; so any individual dice passed in are converted to a dice expression string.

Regards,
JPG

Minty23185Fresh
January 16th, 2021, 19:23
Thank you Moon Wizard, I appreciate your time and your response.

Incidentally, for anyone that cares, I have implemented this functionality in my pseudo dragData (https://www.fantasygrounds.com/forums/showthread.php?48594-On-Demand-(pseudo)-dragdata-Object&p=430958#post430958) object, though I haven't published it yet. I wish to do a little more testing with FGU. To have it work properly I tested various string inputs, e.g. "d20", "d12", "d7", etc. plus others like "2d6", "12d8", "2d4 + 3", "d10 + 4", etc. If the string is not of the simplest form "dN" where N is a whole number, the string that was input is the string you get back out. Makes sense: garbage in, garbage out. :)