-
June 13th, 2021, 10:59 #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);
Ruleset Wizard
The Ruleset Development Environment
www.rulesetwizard.com
Ruleset Wizard Tutorials
Damned's Ruleset Wizard Tutorials
-
June 13th, 2021, 11:45 #2
-
June 13th, 2021, 11:49 #3
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.
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
June 13th, 2021, 11:53 #4
- Join Date
- Apr 2018
- Posts
- 51
Nevermind, Valarian answered it better while I was typing, LOL
-
June 13th, 2021, 11:59 #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
-
June 13th, 2021, 13:07 #6
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);
-
June 13th, 2021, 13:19 #7
- Join Date
- Apr 2018
- Posts
- 51
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.
-
June 13th, 2021, 14:13 #8
CaptJack2883
See about 1/3rd way down this page - 1st example
https://fantasygroundsunity.atlassia...1/Rolling+Dice
-
June 13th, 2021, 15:11 #9
- Join Date
- Apr 2018
- Posts
- 51
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?
-
June 13th, 2021, 16:26 #10
DataCommon.onInit() contains the following line of code:
Code:if not UtilityManager.isClientFGU() then Comm.registerSlashHandler("die", processDie); end
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks