Fantasy Grounds Fridays Pre
Page 1 of 2 12 Last
  1. #1

    Comm.throwDice does not process rolls in the same way as /die?

    the problem is as follows (FGU, CoreRPG, no extensions):

    if you type /die (2*3)d6 in the FG chat correctly rolls 6 dice and display the result.

    if you try to do the same by code, as in the following example:

    Code:
    local rThrow = {};
    rThrow.type = "dice";
    rThrow.description = "description";
    rThrow.secret = false;
    rThrow.shortcuts = {};        
    table.insert(rThrow.shortcuts, {});    
        
    local rRoll = {};
    rRoll.nMod = 0;
    rRoll.aDice = "(2*3)d6";   
       
    local rSlot = {};
    rSlot.number = rRoll.nMod;
    rSlot.dice = rRoll.aDice;
    rSlot.metadata = rRoll;
    rThrow.slots = { rSlot };
                
    Comm.throwDice(rThrow);
    the chat shows the 6d6 message but it only rolls 1d6.
    Ruleset Wizard
    The Ruleset Development Environment
    www.rulesetwizard.com
    Ruleset Wizard Tutorials
    Damned's Ruleset Wizard Tutorials

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    23,935
    Blog Entries
    1
    I can reproduce this.

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  3. #3
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,518
    rRoll.aDice isn't a string. It's an array of dice. To roll six dice, you'd need: rRoll.aDice = {"d6","d6","d6","d6","d6","d6"}

    To make the number of dice dependent on a calculation, you'd need to put the creation of the array into a for loop.
    Code:
    local number = (2*3);
    local type = "d6";
    local dice = {};
    for i = 1, number, 1 do
        table.insert(dice, type);
    end
    Comm.throwDice("dice", dice, bonus, name);
    Last edited by Valarian; June 13th, 2021 at 11:53.
    Current Regular Games: European FG2 RPG

    Using Ultimate FGII - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets - Now also linked in the Wiki

  4. #4
    Nevermind, Valarian answered it better while I was typing, LOL

  5. #5
    Yes, but it can also receive a string instead of an array. It is a feature that was added some time ago. In the example above if you send "6d6" it works.

    The question is why the /die command works with mathematical operations and throwDice does not.
    Ruleset Wizard
    The Ruleset Development Environment
    www.rulesetwizard.com
    Ruleset Wizard Tutorials
    Damned's Ruleset Wizard Tutorials

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    23,935
    Blog Entries
    1
    psicodelix see this post: https://www.fantasygrounds.com/forum...l=1#post549627

    With the most recent update, any Comm.throwDice calls will now rebuild the individual dice entries for you, if dice.expr is set in the table passed to Comm.throwDice, and no individual dice are specified.
    Ex:
    local rThrow = { type = "dice", description = "COMPLEX ROLL", slots = { #1 = { dice = { expr = "4d6d2" }, number = 0 } } };
    Comm.throwDice(rThrow);

    Also, I updated the ActionsManager global script in CoreRPG used by many layered rulesets to pass through roll tables that do not specify individual dice
    Ex:
    local rRoll = { sType = "dice", sDesc = "COMPLEX ROLL", aDice = { expr = "4d6d2" }, nMod = 0 };
    ActionsManager.performAction(nil, nil, rRoll);

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  7. #7
    Quote Originally Posted by psicodelix View Post
    Yes, but it can also receive a string instead of an array. It is a feature that was added some time ago. In the example above if you send "6d6" it works.

    The question is why the /die command works with mathematical operations and throwDice does not.
    It's good to know that I can send dice commands that way. I think I was still using the old way of adding dice so that FGC would cooperate.

    As to the second part, does the /die command use a separate/different parsing function than throwDice? Or do they both call the same function to parse the die rolls?

    Also, the way psicodelix was putting "(2*3)d6" as a string, lua will not convert the 2*3 into 6 before sending it to the die parser. But the /die command might be looking for numbers and doing the math before putting the result into the die string to send to the die parser.

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    23,935
    Blog Entries
    1
    CaptJack2883

    See about 1/3rd way down this page - 1st example

    https://fantasygroundsunity.atlassia...1/Rolling+Dice

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  9. #9
    I guess I should clarify. I knew you could use the /die command inside FG for the complex rolls. I just meant I didn't know you could put "6d6" into rRoll.aDice and have it work inside an extension/ruleset.

    The other part I'm still wondering about. I honestly have no clue how the Comm.throwDice() function is implemented. Does it call the /die command function?

  10. #10
    DataCommon.onInit() contains the following line of code:

    Code:
    if not UtilityManager.isClientFGU() then Comm.registerSlashHandler("die", processDie); end
    So it is apparently different between FGC and FGU. /die is built-in in FGU?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
FG Spreadshirt Swag

Log in

Log in