Log in

View Full Version : Help with skill dice rolls on chat



Claneidosyan
September 5th, 2016, 18:04
Hello!
I hope someone can help me on this one!
I recently started looking into ruleset modifications and, looking at 3.5 ruleset I managed to create a little core extension form my custom game.
For now I only needed a stat sheet and a rollable skill list and I thought it wouldn't be too difficult.
I managed to get a basic understanding of how the databa se works and I created the stat sheet and the skill list.
Ok, I actually adapted the 3.5 skillist :p
Rolling the skill I'd like the chat to show a result compared to the associated stat (If your roll is less or equal the stat it's good and something like that)

The only problem is that dragging or double clicking the total rolls the dice, but no result is shown on chat. The dice is cast, it rolls, it stops and it fades away and nothing is shown.
If I understood the 3.5 skillset correctly, the function "onRoll" is used to print the message.
I tried creating and printing a message in the "performroll" function and it looks like this now.

function performRoll(draginfo, rActor, sSkillName, nSkillMod, sSkillStat, nTargetDC, bSecretRoll, sExtra)
local rRoll = getRoll(rActor, sSkillName, nSkillMod, sSkillStat, nTargetDC, bSecretRoll, sExtra);

ActionsManager.performAction(draginfo, rActor, rRoll);
local rMessage = ActionsManager.createActionMessage("skill", rRoll);
Comm.deliverChatMessage(rMessage);
end

This message is printed in the chat window and it prints the skill label (correctly), the skill total (correct for now), and nothing else. No dice icon shown and no dice result. This is shown just clicking on the dice, without actually throwing it.

I thik the result of the dice roll should be captured by the "ActionsManager.registerResultHandler("skill", onRoll);" call on the onInit function but for now it doesn't work...

What am I doing wrong? Thank you for the help and sorry if I missed something extremely basic ^^"

Trenloe
September 5th, 2016, 18:56
You've fallen into the usual trap. :)

Actions (dice rolling) in FG is asynchronous - the performRoll function rolls the dice with ActionsManager.performAction continues on, it doesn't wait for the dice to finish rolling. The dice roll asynchronously (outside of the performRoll function) and then only once they stop rolling should the chat message be put together. In your code the dice have only just started rolling, so there is no rRoll.aDice results to process - hence why you're not seeing anything.

You are correct that your onRoll event handler should be where you create the action message and send it to the chat window. The gotcha here is that the action type ("skill" in your case) needs to be a recognised action registered with FG. This is usually done in the scripts\manager_gamesystem.lua "actions" table, or via code in your custom actions manager onInit function. For example: GameSystem.actions["skill"] = { bUseModStack = true}; will register the "skill" action with FG's GameSystem package.

The code in this extension is a good example of a simple action handler: https://www.fantasygrounds.com/forums/showthread.php?31425-Basic-success-counting-extension

Trenloe
September 5th, 2016, 18:58
Oh, and welcome to the forums. :)

Claneidosyan
September 5th, 2016, 19:50
It finally works!
That was exactly what I was missing :D
Thank you a lot!
My game session tomorrow well be a lot more comfortable!