Starfinder Playlist
  1. #1

    Auto-totals in chat window?

    My players and I would like to see the sum of each roll plus modifiers automatically displayed (just like when you use the 'Display Sum' option in the radial menu).

    Has anyone figured out how to make this happen automatically?


  2. #2
    No ideas on how to access the dice widget that shows in the chat window? Or how someone might turn on dice totals for all rolls?


  3. #3
    Its not too bad to get the total and modify the message going out. In the chat_chat.lua file on the onDiceLandedEvent on the isType("dice") part, process the results of the roll and send your own message. Make sure you end the code block with a return true unless you want your total on a seperate line.

  4. #4

    Join Date
    Jun 2007
    Zeist, Netherlands
    I still can't read these Lua scripts like I read VBScript or JavaScript.
    Can you help me with this Joshuha? A basic explanation of the entire onDiceLanded function would be highly appreciated.

  5. #5
    Well onDiceLanded is triggered whenever a dice hits the chatwindow. Ignoring the fullattack type check for now (that is a special d20 thing) the part where the magic happens so to speak is relatively small:

    elseif draginfo.isType("dice") then
    You'll see that all this does is call a function that appears earlier in the chat_chat.lua file. Without going into too much detail in this function just know that it scans to see if there is number data in the roll and also applies any number data from the modifier stack to the roll. We really just care about the total afterwards. This is done in the line at the end that says draginfo.setNumberData(...), but again since this is done for us we just need to get that value back out.

    So we can calculate the total pretty easily if we access the dice results which are known at the time this event is fired. So to do that after the applyModifierStackToRoll has done the work of getting the total of all the modifiers we take the dielist, loop through that, and add the numberdata.

    I am not gonna write the code line by line but will provide the building blocks for you. So after the applyModiferStackToRoll function you get the dielist like so:
    local dice = {};
    dice = draginfo.getDieList();
    This is a table of dietypes that have a field of type and result. What we care about in this scenario is result. To access them would be dice[x].result where x is your variable for some sort of loop (whichever way you prefer).

    So over you loop you would total the results, than add the numberdata with a draginfo.getNumberData() and then build a message to display the total.

    Note that if you don't return true at the end of the block you will get your message plus the normal processing of the roll. If you want it to just be your message you can return true and that prevents the default processing on the function (this works for many different event functions in FG).

    If you still need further help let me know but that should be enough to set you down the right path.

  6. #6
    Thanks for the suggestion, joshuha. It's a fairly straightforward hack, though somewhat kloodgy.

    After looking at the scripts and objects, it doesn't look there is a way to access the values actually rolled by the dice.

    Using your method, you would essentially need to use the math.random() function for each die in the dieList, and then display your own totals in the chat window as a regular line of text.

    The result would be that you wouldn't be able to access or re-use the nice dice + modifier chat entry interface already there. Also, the output would not match the die rolls.

    Anybody know how to make a feature request?


  7. #7
    Actually it may not have been clear in my post, in the onDiceLanded event the draginfo has the dieresults already rolled, thats what the result field in a die row is for.

  8. #8
    Thanks for the hints joshuha and the question moon_wizard. I am learning how to do FG rulesets myself. It was pretty simple to make it total the dice and send the total in a new message.

    What I can't figure out is how to make it display the total like in "display sum" in the radial menu (i.e. in the same dice bubble). I scanned through all the XML and Lua and couldn't find any radial menu stuff anywhere to go on. Is that part of the game engine vs. the ruleset?


  9. #9
    Quote Originally Posted by sfcthulhu
    What I can't figure out is how to make it display the total like in "display sum" in the radial menu (i.e. in the same dice bubble). I scanned through all the XML and Lua and couldn't find any radial menu stuff anywhere to go on. Is that part of the game engine vs. the ruleset?
    Is there no hotkey or GM option or something to have it display the sum all the time? I can't understand why the default is to NOT show the total. Is there an argument I can add to my /die command to display the sum?

  10. #10
    As far as I am aware, there is no option or script function to have the dice roll sums shown all the time in the chat window similar to when you select display sum when right-clicking on a roll. I would really like to know if someone has found one.

    In my d20_JPG and 4E_JPG rulesets, I provide an option which totals every roll, and appends the total to the description string. Once the developers enable access to that function, I will be including in my rulesets.


Thread Information

Users Browsing this Thread

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Log in

Log in