5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1

    Registering a custom die roll

    I am new to FGU, and am trying to create what I think is an extremely basic extension to roll exploding 4dF. I'm struggling with something that seems very simple based on numerous GitHub repos I've examined, and that is using `CustomDiceManager.add_roll_type` in my script's onInit.

    I am getting a runtime error saying that `CustomDiceManager` is nil.

    I am assuming I'm missing something in `extension.xml` that is supposed to bring in the core API or maybe CoreRPG?

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <root version="3.3">
        <properties>
            <name>Threa</name>
            <description>Threa Extension for CoreRPG</description>
            <author>Rocky Lhotka</author>
            <version>1.0</version>
            <license>CC-BY-NC-SA 4.0</license>
            <loadorder>1000</loadorder>
            <ruleset>
                <name>CoreRPG</name>
            </ruleset>
        </properties>
    
        <announcement text="Threa Extension for CoreRPG" font="emotefont" />
    3
        <base>
            <!-- Register scripts -->
            <script name="threainit" file="scripts/Threa_init.lua" />
            <script name="threadice" file="scripts/Threa_dice.lua" />
        </base>
    </root>
    In `Threa_dice.lua` my `onInit` is:

    Code:
    function onInit()
        Debug.console("Threa_dice.lua: onInit called");
        -- Register the custom roll type
        if CustomDiceManager then
            CustomDiceManager.add_roll_type("exp", onCustomRoll, onCustomRollLanded, true, "all");
            Debug.console("Threa_dice.lua: Custom roll type 'exp' registered");
        else
            Debug.console("Threa_dice.lua: CustomDiceManager is not available");
        end
    end

  2. #2
    Where is "CustomDiceManager" coming from?
    That's not one of the built-in API packages; nor one of the packages provided in CoreRPG layer. It's not referenced in any code that I've seen.

    If you look at the examples in the built-in rulesets (5E, 4E, 3.5E, etc.); you can make a roll like you are asking by calling:
    Code:
    	local rRoll = { sType = "dice", sDesc = "Roll", aDice = { expr = "4dF!" }, nMod = 0 };
    	ActionsManager.performAction(draginfo, nil, rRoll);
    where the call can be made based on some UI action (button press; click; etc.) or through UI dragging (onDragStart control event).

    Regards,
    JPG

  3. #3
    That is probably my issue - I'm trying to learn this by skimming forums, github repos, etc. and there's a lot of contradictory or incomplete stuff out there. That "CustomDiceManager" is used in a lot of repos without any explicit reference that I can find, so my assumption was that it was built-in.

    What it is _supposed_ to do is make it so I can chat "/roll exp" and get my exploding dice roll.

    I haven't even gotten to the point of figuring out how to create a UI element like a button or UI dragging, so I have no frame of reference for how to trigger an action as you suggest.

    What is the simplest thing you can recommend to trigger my code?

    (also, thanks for the "4dF!" - that is excellent!)

    ---

    For future reference - now that I know it isn't built-in, I did some deeper searching on GitHub and did find at least one instance of where this "CustomDiceManager" is implemented:

    https://github.com/mattkeehan/fg-lua...ustom_dice.lua
    Last edited by illiante; April 8th, 2025 at 18:03.

  4. #4
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    22,051
    You are probably better off staring here https://fantasygroundsunity.atlassia...eveloper+Guide

    Or make a copy of the CoreRPG or 5e rulesets, unzip the copy and study those. Anything on GitHub and other places is likely to be extension code which is not necessarily going to use code that is actually in the rulesets, but rather is added to the existing code, and is use for very specific circumstances.
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea here https://www.fantasygrounds.com/featu...rerequests.php

  5. #5
    You can already make a given dice roll by using a chat command:
    Code:
    /die 4dF!
    Regards,
    JPG

  6. #6
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    18,360
    Blog Entries
    9
    Our resident AI can confirm, but CustomDiceManager sounds like it comes from MoreCore or XCore community rulesets. So you would have to layer on those to actually use it.

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  7. #7
    Quote Originally Posted by Moon Wizard View Post
    You can already make a given dice roll by using a chat command:
    Code:
    /die 4dF!
    Regards,
    JPG
    I tried that, with excitement.

    Unfortunately, it doesn't explode the way our system does. We only explode when 4dF==4, not on individual + dice.

    Which is fine, it means my efforts to create this function haven't been wasted after all.

  8. #8
    Quote Originally Posted by Zacchaeus View Post
    You are probably better off staring here https://fantasygroundsunity.atlassia...eveloper+Guide

    Or make a copy of the CoreRPG or 5e rulesets, unzip the copy and study those. Anything on GitHub and other places is likely to be extension code which is not necessarily going to use code that is actually in the rulesets, but rather is added to the existing code, and is use for very specific circumstances.
    I was hoping to avoid creating a whole new ruleset, but rather building an extension to CoreRPG. I have yet to find any good walkthrough or tutorial on how to do such a thing, so I've been muddling through all the stuff I can find via google and various AI chatbots. Pretty painful so far I'm afraid - as I'm new to FGU and lua (though have 35+ years experience as a developer, so not _entirely_ without resources).

  9. #9
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    22,051
    I should have linked the part relating to extensions rather than the whole thing. I wasn't suggesting that you create a new ruleset but understanding how the ruleset works might help in understanding how extensions fit in. At any rate this was the bit that I really was referring you to https://fantasygroundsunity.atlassia...e+-+Extensions
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea here https://www.fantasygrounds.com/featu...rerequests.php

  10. #10
    Quote Originally Posted by Zacchaeus View Post
    I should have linked the part relating to extensions rather than the whole thing. I wasn't suggesting that you create a new ruleset but understanding how the ruleset works might help in understanding how extensions fit in. At any rate this was the bit that I really was referring you to https://fantasygroundsunity.atlassia...e+-+Extensions
    Thank you for that link, that is very helpful.

    When it says to copy and modify an existing extension - that makes sense - but the only extensions I have on my machine are themes. Is there a good (simple) start point that shows how to enhance the CoreRPG character sheet?

Page 1 of 2 12 Last

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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
  •  
GI JOE RPG Launch

Log in

Log in