-
May 24th, 2021, 10:13 #1
Return the result of a table roll inside script
Morning All,
Is there a way to handle the result of a Table roll?
Inside Traveller we have the Critical Tables and rather than build a new roll type, it would just be simpler if I could roll the table and get back the result.
I can't see how to do this as there's no documentation that I can find on the Table Manager.
This code rolls the dice and outputs the result to the Chat, perfect, now I just need to know what it rolled.
Code:TableManager.processTableRoll("", "Spacecraft Critical Hits Location");
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
May 24th, 2021, 13:17 #2
Rolling on a table is like other rolls - they're asynchronous and the result is processed in the registered ActionsManager result handler, in this case onTableRoll, and you can only have one result handler.
So, short of extending onTableRoll to handle another type of output, you may just be better "rolling" using a math.random and then using the result to do the lookup yourself - directly at the table. Or, if the data in the table doesn't change, you may want to code it as a LUA record (LUA table) and access the data directly through code. The older Star Wars EotE ruleset did this for it's critical hit resolution - there's an example extension for the LUA table here: https://www.fantasygrounds.com/forum...Text-extension The code to do the lookup is in the ruleset - but it's just a simple math.random call and then finds the entry in the LUA table that is within the d100_start and d100_end results.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!
-
May 24th, 2021, 17:49 #3
Hi Chap,
Thanks for letting me know.
I don't like hidden results, so I'll add another dice roll type and plug all that in, I can re-task some existing code.
And the idea of the Lua table is spot on, I already have one, that shows what critical location and what effect depending on the level. Hence if I could get the dice roll from the table then it's just linking the two.
Cheers,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
May 25th, 2021, 08:57 #4
- Join Date
- Apr 2018
- Posts
- 51
I have been doing a custom roll type by assigning a custom string value to rRoll.sType, then making my own result handler to pick up those rolls. Perhaps you can do something similar?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks