Starfinder Playlist
Page 1 of 3 123 Last
  1. #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 });
    When I view rTurnHDRoll in debug

    Code:
    Debug.console("manager_action_turnundead.lua","onRoll","rTurnHDRoll",rTurnHDRoll);
    I see...

    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' }
    You'll notice there is not a "result = #SomeNumber" there. What I want to do is make those rolls and get the value. I've reviewed various functions that do rolls and use rRoll style and they all seem to get a "result" key in the end run...

    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.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    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!

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    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!

  4. #4

    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.

  5. #5
    Quote Originally Posted by Trenloe View Post
    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.
    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.

    Quote Originally Posted by Trenloe View Post
    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.

  6. #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.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by celestian View Post
    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 }
    Yeah, you see you have the result for each individual dice as well as the total. This is only available after the dice have fully landed, and not in the same function as when the roll is initiated.
    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!

  8. #8
    Quote Originally Posted by Trenloe View Post
    Yeah, you see you have the result for each individual dice as well as the total. This is only available after the dice have fully landed, and not in the same function as when the roll is initiated.
    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.

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by celestian View Post
    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.
    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!

  10. #10
    Quote Originally Posted by Trenloe View Post
    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.
    Good point, I did note the draginfo portion, I'll poke around that. What I ended up doing in the meantime was pulling the <targets> node from the rSource. It worked but I'll see if I can work in rTarget instead.
    ---
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in