Thread: Dice rolling, with dice...
-
February 17th, 2018, 04:53 #1
Dice rolling, with dice...
So this is probably something I'm just missing that's simple. I'm trying to roll 2d6 and 2d4 and get the result. The dice roll and a result shows in chat but... I can't programmatically get the value of the rolled result. Here is how I do the rolls. (I've tried performAction and actionDirect).
Code:local rTurnHDRoll = { sType = "dice", sDesc = "Turn Undead", aDice = aTurnDice, nMod = 0 }; --ActionsManager.performAction(nil, nil, rTurnHDRoll); ActionsManager.actionDirect(nil, "dice", { rTurnHDRoll });
Code:Debug.console("manager_action_turnundead.lua","onRoll","rTurnHDRoll",rTurnHDRoll);
Code:Runtime Notice: s'manager_action_turnundead.lua' | s'onRoll' | s'rTurnHDRoll' | { s'sType' = s'dice', s'aDice' = { #1 = s'd6', #2 = s'd6', #3 = s'd4', #4 = s'd4' }, s'nMod' = #0, s'sDesc' = s'Turn Undead' }
Is there a another function I'm missing that will do this? I can write something to do this but surely I'm just blind?Last edited by celestian; February 17th, 2018 at 04:55.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
February 17th, 2018, 13:26 #2
That debug looks like no results are available - individual dice nor the total result. Where do you have the debug code? You’ll need to look in the final result handler in a different function to where you call the actionDirect function. Rolling is asynchronous, FG doesn’t stop a function waiting for the result of the roll, it needs to be looked at in the result handler function.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 17th, 2018, 13:29 #3
See step 5 here: https://www.fantasygrounds.com/forum...l=1#post307397
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 17th, 2018, 15:17 #4
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Trenloe, that is an outstanding post. I agree with Dulux that it should be in the wiki, but I think it needs to be in a "useful forum posts" kind of section that links back to it rather than trying to duplicate posts onto the Wiki.
-
February 17th, 2018, 16:36 #5
It's there, it's just in the "code" mode and doesn't wrap.
Runtime Notice: s'manager_action_turnundead.lua' | s'onRoll' | s'rTurnHDRoll' | { s'sType' = s'dice', s'aDice' = { #1 = s'd6', #2 = s'd6', #3 = s'd4', #4 = s'd4' }, s'nMod' = #0, s'sDesc' = s'Turn Undead' }
2d6 and 2d4.
I'll check it out, thanks
So, I've done this before (infact the turn undead does just what you're suggesting) but I don't think I need the onRoll bit unless that hook somehow is setting rRoll.result?
"local nTotal = ActionsManager.total(rTurnHDRoll);"
This part fails for rTurnHDRoll after "ActionsManager.performAction(nil, rSource, rTurnHDRoll);" runs. rTurnHDRoll does not have rTurnHDRoll.result set.Last edited by celestian; February 17th, 2018 at 16:40.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
February 17th, 2018, 17:00 #6
Okay, so I created another onRoll_TurnCount and added the handler for this and it does set the .result values there... I was hoping I could handle the output for the results in the same place as the other but guess that is not going to be possible.
This is from within the "turnundead" onRoll:
Runtime Notice: s'manager_action_turnundead.lua' | s'onRoll' | s'rTurnHDRoll' | { s'aDice' = { #1 = s'd6', #2 = s'd6', #3 = s'd4', #4 = s'd4' }, s'nMod' = #0, s'sType' = s'turnundead_count', s'bSecret' = bFALSE, s'nTarget' = #99, s'sDesc' = s'Turn Undead' }
This is in the onRoll_TurnCount for type turnundead_count.:
Runtime Notice: s'manager_action_turnundead.lua' | s'onRoll_TurnCount' | s'rRoll' | { s'aDice' = { #1 = { s'result' = #2, s'type' = s'd6' }, #2 = { s'result' = #6, s'type' = s'd6' }, #3 = { s'result' = #2, s'type' = s'd4' }, #4 = { s'result' = #3, s'type' = s'd4' } }, s'nMod' = #0, s'sType' = s'turnundead_count', s'sDesc' = s'Turn Undead', s'nTarget' = s'99', s'bSecret' = bFALSE }
Runtime Notice: s'manager_action_turnundead.lua' | s'onRoll_TurnCount' | s'nTotal' | #13
So it seems it doesn't even get the result until after the fact so... I'll see what I can do
Thanks for the pointer and insight.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
February 17th, 2018, 17:48 #7Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 18th, 2018, 04:28 #8
Is there some similar magic to get "rTarget" to be populated? The action doesn't seem to populate rTarget even if a target(s) are selected by the actor.
onRoll and modRoll both show rTarget = nil. I've been going over manager_action_attack and _damage but can't seem to see the immediate cause yet.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
February 18th, 2018, 13:31 #9
Targeting is usually encapsulated in the draginfo data structure - for both dragging and the targeting system.
ActionsManager.actionDirect does not use targeting.
ActionsManager.performAction does use targeting if the draginfo data structure is included.
In the 5E ruleset, have a look at how the attack or damage actions are initiated from the weapon record. Look at campaign\scripts\char_weapon.lua - the onAttackAction and onDamageAction functions, these both call the relevant action handler "performRoll" functions including draginfo.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 18th, 2018, 18:36 #10---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks