Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    Sorting dice results in chat output

    I was able to modify the manager_actions.lua to not show the total of the dice rolled, but have been unable to figure out a way to sort the results by value. I would like to have the output message sorted low to high on the dice results, regardless of the die size. Any help?

  2. #2
    You don't really want to override ActionsManager, as that is one of the very low level scripts that drives rolls in the CoreRPG layer.

    If you want to turn off the dice total for specific rolls, just set "rMessage.dicedisplay = 0" on the result message passed to ActionsManager.messageResult or Comm.deliverChatMessage.

    Regards,
    JPG

  3. #3
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    This code can help you sort the dice into order:

    Code:
      table.sort(rRoll.aDice, function(a,b) return a.result > b.result end);

  4. #4
    Quote Originally Posted by Moon Wizard View Post
    You don't really want to override ActionsManager, as that is one of the very low level scripts that drives rolls in the CoreRPG layer.

    If you want to turn off the dice total for specific rolls, just set "rMessage.dicedisplay = 0" on the result message passed to ActionsManager.messageResult or Comm.deliverChatMessage.

    Regards,
    JPG
    Think that is what I did, but just to make sure...

    -- Build the basic message to deliver
    local rMessage = ChatManager.createBaseMessage(rSource, rRoll.sUser);
    rMessage.type = rRoll.sType;
    rMessage.text = rMessage.text .. sDesc;
    rMessage.dice = rRoll.aDice;
    rMessage.diemodifier = rRoll.nMod;
    rMessage.diceskipexpr = rRoll.diceskipexpr;
    rMessage.dicedisplay = 0;


    If that is not the right place to add it, please let me know. It does seem to be working correctly, though.

  5. #5
    Quote Originally Posted by damned View Post
    This code can help you sort the dice into order:

    Code:
      table.sort(rRoll.aDice, function(a,b) return a.result > b.result end);
    First off, thanks. Your original post put me in the right direction to set up removing the totals. Second, where would I insert this code?

  6. #6
    Yes, but by modifying the ActionsManager, you are affecting every roll in the system, including rolls that shouldn't be affected (such as table rolls). By setting that information after getting the rMessage table back from ActionsManager, you don't need to modify ActionsManager at all, and it will only affect specific rolls that shouldn't display the total.

    Regards,
    JPG

  7. #7
    Quote Originally Posted by Moon Wizard View Post
    Yes, but by modifying the ActionsManager, you are affecting every roll in the system, including rolls that shouldn't be affected (such as table rolls). By setting that information after getting the rMessage table back from ActionsManager, you don't need to modify ActionsManager at all, and it will only affect specific rolls that shouldn't display the total.

    Regards,
    JPG
    Ok. Will see how I can apply that to what I am doing. Thanks for the advice. This is for a build of Sentinel Comics RPG and I am using Ian Ward's Dice Pool extension, so those are really the only rolls that I do not need totals on.

    Honestly, I am kinda sledgehammer programming, so mostly just get lucky in figuring out what I am doing...
    Last edited by Joram Mistwalker; July 26th, 2022 at 02:45.

  8. #8
    No worries; I just like to give advice to make sure people's stuff works the longest without any CoreRPG ruleset changes having an impact.

    Cheers,
    JPG

  9. #9

  10. #10
    Quote Originally Posted by damned View Post
    This is not a simple post/thread but it is what you should try and get your head around -

    https://www.fantasygrounds.com/forum...ns)-in-CoreRPG
    Yeah, I have tried to dig into that post a couple of times before. Have not been very successful, but really need to try again. Thanks.

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
  •  
FG Spreadshirt Swag

Log in

Log in