Thread: Registering a custom die roll
-
April 8th, 2025, 16:55 #1
- Join Date
- Dec 2024
- Posts
- 5
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>
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
-
April 8th, 2025, 17:39 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 22,204
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);
Regards,
JPG
-
April 8th, 2025, 17:54 #3
- Join Date
- Dec 2024
- Posts
- 5
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.luaLast edited by illiante; April 8th, 2025 at 18:03.
-
April 8th, 2025, 18:48 #4
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
-
April 8th, 2025, 19:15 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 22,204
You can already make a given dice roll by using a chat command:
Code:/die 4dF!
JPG
-
April 8th, 2025, 20:15 #6
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.
-
April 8th, 2025, 22:17 #7
- Join Date
- Dec 2024
- Posts
- 5
-
April 8th, 2025, 22:20 #8
- Join Date
- Dec 2024
- Posts
- 5
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).
-
April 8th, 2025, 22:38 #9
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
-
April 8th, 2025, 22:51 #10
- Join Date
- Dec 2024
- Posts
- 5
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?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks