Log in

View Full Version : Dice roll result shown twice



Drakula
April 5th, 2023, 17:13
I have discovered a bug in FGU where if you override the ActionsManager.onDiceLanded function the chat output is shown twice (see image)

56969

The bottom result is the error one (as you can see it doesn't show the GM icon) I have been able to recreate this with a new extension that does nothing else but this, here is the code


function onInit()
if ActionsManager.onDiceLanded then
old_onDiceLanded = ActionsManager.onDiceLanded;
end
ActionsManager.onDiceLanded = test_onDiceLanded;
end

function test_onDiceLanded(dragdata)
if old_onDiceLanded then
old_onDiceLanded(dragdata);
end
end

All it does is call the old onDiceLanded, if I remove the override code (in onInit) the output returns to normal (only shows the top output in the image).

56970

However if I remove the code from test_onDiceLanded and have it do nothing then (as expected) it doesn't show the top result but it still shows the bottom result

56971

This doesn't affect the usage of the roll (e.g. checking if hit or applying damage delt) so it is not a critical error, however it is annoying having all dice rolls show in chat twice.

This is a bug that has existed for some time as I hadn't updated FGU since the LOS and Lighting were added but when I discovered the bug I updated to the latest version (v4.3.7 2023-03-28) and it is still there. I tried looking for a post about this but couldn't find one probably because overriding onDiceLanded hasn't been tried before, or at least not very often, so it hasn't been noticed/reported before.

I understand this isn't a game breaking bug so don't expect it to be a high priority or anything so if anyone can think of a way I could fix it myself that would be great, but other than that I just wanted to let the dev know about it.

Thanks.

<edit>
I forgot to mention that I am using 5e ruleset
</edit>

superteddy57
April 5th, 2023, 17:28
What is the goal for your extension? The best way to inject into the action managers is to register dice rolls using the built in registration functions.

Those would be:
ActionManager.registerTargetingHandler
ActionManager.registerModHandler
ActionManager.registerPostRollHandler
ActionManager.registerResultHandler

Each of those inject into different stages of the dice roll and can affect the dice roll. So could you elaborate more on why you are overriding that function to better understand the logic of your code?

Drakula
April 5th, 2023, 18:27
I am using it to check when a player casts a spell, check what level the spell is and if it is being cast at a higher level (by how many dice are used) and then checking if they have an available spell slot for the required level. If they do then it would mark off the spell slot and if they don't it will prevent the spell effects (damage etc) from being processed.

I am overriding onDiceLanded as it is not just additive it is sometimes preventative as well.

Moon Wizard
April 6th, 2023, 06:31
Make sure that you are returning "true" to the onDiceLanded event callback, or the default processing will also happen. You have to let the FG engine know that you fully handled the event. That's why the default onDiceLanded code does a "return ActionsManager.onDiceLanded(draginfo);"

Regards,
JPG

Drakula
April 6th, 2023, 11:48
Excellent, that fixed it. For some reason every time I looked at the ActionsManager.onDiceLanded() function I just never noticed it was returning true (Doh!)

Thank You.