Starfinder Playlist
  1. #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");
    Cheers,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    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!

  3. #3
    Quote Originally Posted by Trenloe View Post
    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.
    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,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in