DICE PACKS BUNDLE
Page 3 of 3 First 1 2 3
  1. #21
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,002
    You can replace the rolled dice list inside a die handler, intercepting the results and replacing them with a new die list for output to the chat message. This is what I do for Yggdrasill. Replace the rolled list (of 3 or 4 dice) with the sorted list (of 2 or 1). Inside the die handler, I choose the highest results to display to the chat log.
    Code:
    -- This file is part of the Fantasy Grounds Open Foundation Ruleset project. 
    -- For the latest information, see https://www.fantasygrounds.com/
    --
    -- Copyright 2008 SmiteWorks Ltd.
    --
    -- This file is provided under the Open Game License version 1.0a
    -- Refer to the license.html file for the full license text
    --
    -- All producers of work derived from this material are advised to
    -- familiarize themselves with the license, and to take special
    -- care in providing the definition of Product Identity (as specified
    -- by the OGL) in their products.
    --
    -- All material submitted to the Open Foundation Ruleset project must
    -- contain this notice in a manner applicable to the source file type.
    
    function onInit()
      ActionsManager.registerResultHandler("skilldice", handleSkillDice);
    end
    
    function handleSkillDice(rSource, rTarget, rRoll)
        local reroll = false;
        local total = {};
        
        local firstResult = 0;
        local secondResult = 0;
        local dicetable = rRoll.aDice;
        if dicetable then
          for n = 1, table.maxn(dicetable) do
            if dicetable[n].type == "d10" then
              if firstResult > 0 and dicetable[n].result > secondResult then
                secondResult = dicetable[n].result;
                total[2] = dicetable[n];
              elseif dicetable[n].result > firstResult then
                firstResult = dicetable[n].result;
                total[1] = dicetable[n];
              end
            end
          end
        end
        
        if firstResult == 10 or secondResult == 10 then
          repeat
            local reroll = false;
            local dieRoll = math.random(1,10);
            local explode = {};
            explode.type = "d10";
            explode.result = dieRoll;
            table.insert(total, explode);
            -- Purely for effect - roll a d10
            local dice = {};
            table.insert(dice, "d10");
            Comm.throwDice("explode", dice, 0, "explode");
            if dieRoll == 10 then
              reroll = true;
            end
          until not reroll
        end
        
        local rMessage = ChatManager.createBaseMessage(rSource, rRoll.sUser);
        rMessage.type = rRoll.sType;
        rMessage.text = rMessage.text .. rRoll.sDesc;
        rMessage.dice = total;
        rMessage.diemodifier = rRoll.nMod;
        
        -- Check to see if this roll should be secret (GM or dice tower tag)
        if rRoll.bSecret then
          rMessage.secret = true;
          if rRoll.bTower then
            rMessage.icon = "dicetower_icon";
          end
        elseif User.isHost() and OptionsManager.isOption("REVL", "off") then
          rMessage.secret = true;
        end
        
        -- Show total if option enabled
        if OptionsManager.isOption("TOTL", "on") and total and #(total) > 0 then
          rMessage.dicedisplay = 1;
        end
      
        Comm.deliverChatMessage(rMessage);
        ModifierStack.reset();
        return true;
    end
    The issue I'm currently struggling with is the modifier stack. It seems to work for dragging the dice but not for the double-click (where I use Comm.throwDice instead of draginfo). I can't seem to create a draginfo object for the double-click function to use, and the separated throwDice function seems to clear and overwrite the modifier stack.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  2. #22
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,370
    That example is how you usually do it, but in my case I want to truely intercept with existing handlers. For instance, you have 4E ruleset which implements "ability" handlers. What I wanted to do is intercept "ability" handlers by managing rolled dices as exploded ones and replace results with new ones, then let the flow continue in original handlers. I don't want to affect existing handlers at all, just apply interceptors between them. This way you could easily implement new dice interceptors such as exploding dices outside the core logic. However like mentioned, I was not able to succeed on this. Maybe I will double check since I cannot see reason why setDieList after onDiceLanded would kill this approach. Maybe it's something beyond visible API
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  3. #23
    Quote Originally Posted by AstaSyneri View Post
    Care to explain what your workaround is?
    There wasn't one, really - I just got very offended by some rather insulting comments directed at me and the way the mods handled it and left the boards to cool off for a while.
    Since this thread now shows up high on Google when simply looking for virtual tabletops supporting R&K, I figured I should probably clarify that.

    Initiative remains the main stumbling block for automating this ruleset, and I'm contemplating using Tabletop Simulator of all things to handle it, possibly next to FG as a diceroller to help with the math overload R&K can cause.

  4. #24
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    24,754
    Blog Entries
    1
    Hello gurus - can anyone help me modify this script so that it displays the characters portrait and name when the roll is executed?
    I can add the name but all other rolls also display the portrait and I cant work it out...

    Im also trying to expand the /rnk to use any d?? that is passed to it and while that is a whole other story feel free to chime in if you have some pointers there too!
    If you want the code at the point I have it to let me know...

    Im pulling these into the MoreCore ruleset so they are more easily available.

  5. #25
    Quote Originally Posted by damned View Post
    If you want the code at the point I have it to let me know...
    Yes please

  6. #26
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    24,754
    Blog Entries
    1
    Quote Originally Posted by spite View Post
    Yes please
    hey Spite - it can be found in MoreCore - the file you are looking for is:
    /desktop/scripts/morecore_ikael_dicemechanics.lua
    from memory this might also require:
    /desktop/ikael_desktop_classes.xml

  7. #27
    Thanks damned. I plan to try figuring this out this week. I hope you're all prepared for more questions when I inevitably break something.

  8. #28
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    24,754
    Blog Entries
    1
    Quote Originally Posted by spite View Post
    Thanks damned. I plan to try figuring this out this week. I hope you're all prepared for more questions when I inevitably break something.
    Ask away but be warned Im not much good at Dice Rollers...

Page 3 of 3 First 1 2 3

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
  •  
Fantasy Grounds Merchandise

Log in

Log in