STAR TREK 2d20
  1. #1

    Hiding die rolls

    Ok, I think I'm losing my mind.
    I knocked out a quick extension for my home game to hide initiaitive and insight rolls from the players.
    I'm sure it was working, but as of last week it's not hiding the rolls, they are visible to all.
    I basically added the following to the initiative function

    rRoll.bSecret = true;
    rRoll.bTower = true
    The script is posted below, what have I done wrong ?


    Code:
    function onInit()
    ActionsManager.registerModHandler("skill", modRoll);
    ActionsManager.registerModHandler("init", HideInit);
    end
    
    function modRoll(rSource, rTarget, rRoll)
     local aAddDesc = {};
     local aAddDice = {};
     local nAddMod = 0;
     local bADV = false;
     local bDIS = false;
     if rRoll.sDesc:match(" %[ADV%]") then
      bADV = true;
      rRoll.sDesc = rRoll.sDesc:gsub(" %[ADV%]", "");
     end
     if rRoll.sDesc:match(" %[DIS%]") then
      bDIS = true;
      rRoll.sDesc = rRoll.sDesc:gsub(" %[DIS%]", "");
     end
     if rSource then
      local bEffects = false;
      -- Get ability used
      local sActionStat = nil;
      local sAbility = string.match(rRoll.sDesc, "%[CHECK%] (%w+)");
      local sSkill = StringManager.trim(string.match(rRoll.sDesc, "%[SKILL%] ([^[]+)"));
      if not sAbility and sSkill then
       sAbility = string.match(rRoll.sDesc, "%[MOD:(%w+)%]");
       if sAbility then
        sAbility = DataCommon.ability_stol[sAbility];
       else
        local sSkillLower = sSkill:lower();
        if sSkillLower=="insight" then
        rRoll.bSecret = true;
        rRoll.bTower = true
        end
        for k, v in pairs(DataCommon.skilldata) do
         if k:lower() == sSkillLower then
          sAbility = v.stat;
         end
        end
       end
      end
      if sAbility then
       sAbility = string.lower(sAbility);
      end
      -- Build filters
      local aCheckFilter = {};
      if sAbility then
       table.insert(aCheckFilter, sAbility);
      end
      local aSkillFilter = {};
      if sSkill then
       table.insert(aSkillFilter, sSkill:lower());
      end
      -- Get roll effect modifiers
      local nEffectCount;
      aAddDice, nAddMod, nEffectCount = EffectManager5E.getEffectsBonus(rSource, {"CHECK"}, false, aCheckFilter);
      if (nEffectCount > 0) then
       bEffects = true;
      end
      local aSkillAddDice, nSkillAddMod, nSkillEffectCount = EffectManager5E.getEffectsBonus(rSource, {"SKILL"}, false, aSkillFilter);
      if (nSkillEffectCount > 0) then
       bEffects = true;
       for _,v in ipairs(aSkillAddDice) do
        table.insert(aAddDice, v);
       end
       nAddMod = nAddMod + nSkillAddMod;
      end
      
      -- Get condition modifiers
      if EffectManager5E.hasEffectCondition(rSource, "ADVSKILL") then
       bADV = true;
       bEffects = true;
      elseif #(EffectManager5E.getEffectsByType(rSource, "ADVSKILL", aSkillFilter)) > 0 then
       bADV = true;
       bEffects = true;
      elseif EffectManager5E.hasEffectCondition(rSource, "ADVCHK") then
       bADV = true;
       bEffects = true;
      elseif #(EffectManager5E.getEffectsByType(rSource, "ADVCHK", aCheckFilter)) > 0 then
       bADV = true;
       bEffects = true;
      end
      if EffectManager5E.hasEffectCondition(rSource, "DISSKILL") then
       bDIS = true;
       bEffects = true;
      elseif #(EffectManager5E.getEffectsByType(rSource, "DISSKILL", aSkillFilter)) > 0 then
       bDIS = true;
       bEffects = true;
      elseif EffectManager5E.hasEffectCondition(rSource, "DISCHK") then
       bDIS = true;
       bEffects = true;
      elseif #(EffectManager5E.getEffectsByType(rSource, "DISCHK", aCheckFilter)) > 0 then
       bDIS = true;
       bEffects = true;
      end
      if EffectManager5E.hasEffectCondition(rSource, "Frightened") then
       bDIS = true;
       bEffects = true;
      end
      if EffectManager5E.hasEffectCondition(rSource, "Intoxicated") then
       bDIS = true;
       bEffects = true;
      end
      if EffectManager5E.hasEffectCondition(rSource, "Poisoned") then
       bDIS = true;
       bEffects = true;
      end
      if StringManager.contains({ "strength", "dexterity", "constitution" }, sAbility) then
       if EffectManager5E.hasEffectCondition(rSource, "Encumbered") then
        bEffects = true;
        bDIS = true;
       end
      end
      -- Get ability modifiers
      local nBonusStat, nBonusEffects = ActorManager2.getAbilityEffectsBonus(rSource, sAbility);
      if nBonusEffects > 0 then
       bEffects = true;
       nAddMod = nAddMod + nBonusStat;
      end
      
      -- Get exhaustion modifiers
      local nExhaustMod, nExhaustCount = EffectManager5E.getEffectsBonus(rSource, {"EXHAUSTION"}, true);
      if nExhaustCount > 0 then
       bEffects = true;
       if nExhaustMod >= 1 then
        bDIS = true;
       end
      end
      
      -- If effects happened, then add note
      if bEffects then
       local sEffects = "";
       local sMod = StringManager.convertDiceToString(aAddDice, nAddMod, true);
       if sMod ~= "" then
        sEffects = "[" .. Interface.getString("effects_tag") .. " " .. sMod .. "]";
       else
        sEffects = "[" .. Interface.getString("effects_tag") .. "]";
       end
       table.insert(aAddDesc, sEffects);
      end
     end
     
     if #aAddDesc > 0 then
      rRoll.sDesc = rRoll.sDesc .. " " .. table.concat(aAddDesc, " ");
     end
     ActionsManager2.encodeDesktopMods(rRoll);
     for _,vDie in ipairs(aAddDice) do
      if vDie:sub(1,1) == "-" then
       table.insert(rRoll.aDice, "-p" .. vDie:sub(3));
      else
       table.insert(rRoll.aDice, "p" .. vDie:sub(2));
      end
     end
     rRoll.nMod = rRoll.nMod + nAddMod;
     
     ActionsManager2.encodeAdvantage(rRoll, bADV, bDIS);
    end
    
    function HideInit (rSource, rTarget, rRoll)
    Debug.console("rRoll",rRoll)
     local bADV = false;
     local bDIS = false;
     if rRoll.sDesc:match(" %[ADV%]") then
      bADV = true;
      rRoll.sDesc = rRoll.sDesc:gsub(" %[ADV%]", "");
     end
     if rRoll.sDesc:match(" %[DIS%]") then
      bDIS = true;
      rRoll.sDesc = rRoll.sDesc:gsub(" %[DIS%]", "");
     end
     if rSource then
      local bEffects, aEffectDice, nEffectMod, bEffectADV, bEffectDIS = ActionInit.getEffectAdjustments(rSource);
      if bEffects then
       for _,vDie in ipairs(aEffectDice) do
        if vDie:sub(1,1) == "-" then
         table.insert(rRoll.aDice, "-p" .. vDie:sub(3));
        else
         table.insert(rRoll.aDice, "p" .. vDie:sub(2));
        end
       end
       rRoll.nMod = rRoll.nMod + nEffectMod;
       if bEffectADV then
        bADV = true;
       end
       if bEffectDIS then
        bDIS = true;
       end
       local sEffects = "";
       local sMod = StringManager.convertDiceToString(aEffectDice, nEffectMod, true);
       if sMod ~= "" then
        sEffects = "[" .. Interface.getString("effects_tag") .. " " .. sMod .. "]";
       else
        sEffects = "[" .. Interface.getString("effects_tag") .. "]";
       end
       rRoll.sDesc = rRoll.sDesc .. " " .. sEffects;
      end
     end
     rRoll.bSecret = true;
     rRoll.bTower = true
     ActionsManager2.encodeDesktopMods(rRoll);
     ActionsManager2.encodeAdvantage(rRoll, bADV, bDIS);
    end
    Cheers, Steve.

    *Edit* I'm pretty confident the above code was working up until the latest update to Fantasy Grounds, maybe something got changed in the way the dice tower operates?
    Last edited by Stv; March 22nd, 2020 at 12:35.

  2. #2
    Just double checked with my DM, and he confirmed that the above was working previously
    Any chance a dev can take a look and see if anything has been changed recently regarding tower rolls?

    Cheers, Steve.

  3. #3
    We are currently swamped with getting FGU stabilized right now; so hopefully one of the community devs can help, or you'll have to hit me up in a few weeks when I have time to look at things like this again.

    Regards,
    JPG

  4. #4
    No worries Moon, thanks for the reply.
    Keep bashing on getting FGU ready, we all want that ready as soon as possible

    Cheers, Steve.

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
  •  
DICE PACKS BUNDLE

Log in

Log in