From 9b54524466e786a6b2c00809ba5eba30ac2de03f Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Tue, 8 Feb 2022 04:32:04 -0700 Subject: [PATCH 1/7] Use local storage for old function. Minor formatting refactors. --- scripts/aspect_of_the_beast_bear.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/aspect_of_the_beast_bear.lua b/scripts/aspect_of_the_beast_bear.lua index 8b03c72..5a24337 100644 --- a/scripts/aspect_of_the_beast_bear.lua +++ b/scripts/aspect_of_the_beast_bear.lua @@ -1,12 +1,7 @@ --- (c) Copyright Justin Freitas 2021+ except where explicitly stated otherwise. --- Fantasy Grounds is Copyright (c) 2004-2021 SmiteWorks USA LLC. --- Copyright to other material within this file may be held by other Individuals and/or Entities. --- Nothing in or from this LUA file in printed, electronic and/or any other form may be used, copied, --- transmitted or otherwise manipulated in ANY way without the explicit written consent of --- Justin Freitas or, where applicable, any and all other Copyright holders. +local getEncumbranceMult_orig function onInit() - CharManager.getEncumbranceMultAspectOfTheBeastBear = CharManager.getEncumbranceMult + getEncumbranceMult_orig = CharManager.getEncumbranceMult CharManager.getEncumbranceMult = getEncumbranceMultOverride local featureNamePath = "charsheet.*.featurelist.*.name" @@ -17,7 +12,7 @@ end -- This is entered on strength change or trait change (not feature) due to the way record_char_inventory.xml works. -- See: function getEncumbranceMultOverride(nodeChar) - local mult = CharManager.getEncumbranceMultAspectOfTheBeastBear(nodeChar) + local mult = getEncumbranceMult_orig(nodeChar) if isBarbarianOfLevelSixOrHigher(nodeChar) and hasAspectOfTheBeastBear(nodeChar) then mult = mult * 2 end @@ -27,7 +22,8 @@ end function hasAspectOfTheBeastBear(nodeChar) for _, nodeFeature in pairs(DB.getChildren(nodeChar, "featurelist")) do - if string.match(DB.getValue(nodeFeature, "name", ""):lower(), "^%W*aspect%W+of%W+the%W+beast%W*bear%W*$") then + local name = DB.getValue(nodeFeature, "name", ""):lower() + if string.match(name, "^%W*aspect%W+of%W+the%W+beast%W*bear%W*$") then return true end end @@ -37,7 +33,8 @@ end function isBarbarianOfLevelSixOrHigher(nodeChar) for _, nodeClass in pairs(DB.getChildren(nodeChar, "classes")) do - if DB.getValue(nodeClass, "name", ""):lower() == "barbarian" and DB.getValue(nodeClass, "level", 0) >= 6 then + if DB.getValue(nodeClass, "name", ""):lower() == "barbarian" and + DB.getValue(nodeClass, "level", 0) >= 6 then return true end end @@ -55,9 +52,12 @@ function onFeatureNameAddOrUpdate(nodeFeatureName) end function updateInventoryPaneEncumbranceBaseIfLoaded(w) - if not (w and w.inventory and w.inventory.subwindow and w.inventory.subwindow.contents and w.inventory.subwindow.contents.subwindow - and w.inventory.subwindow.contents.subwindow.encumbrancebase - and w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated) then return end + if not (w and w.inventory + and w.inventory.subwindow + and w.inventory.subwindow.contents + and w.inventory.subwindow.contents.subwindow + and w.inventory.subwindow.contents.subwindow.encumbrancebase + and w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated) then return end -- See: w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated() From 4138b5b33da50432325506c45a4bebc015160d95 Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Tue, 8 Feb 2022 04:35:14 -0700 Subject: [PATCH 2/7] Newlines. --- scripts/aspect_of_the_beast_bear.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/aspect_of_the_beast_bear.lua b/scripts/aspect_of_the_beast_bear.lua index 5a24337..7780da2 100644 --- a/scripts/aspect_of_the_beast_bear.lua +++ b/scripts/aspect_of_the_beast_bear.lua @@ -9,11 +9,13 @@ function onInit() DB.addHandler(featureNamePath, "onUpdate", onFeatureNameAddOrUpdate) end --- This is entered on strength change or trait change (not feature) due to the way record_char_inventory.xml works. +-- This is entered on strength change or trait change (not feature) +-- due to the way record_char_inventory.xml works. -- See: function getEncumbranceMultOverride(nodeChar) local mult = getEncumbranceMult_orig(nodeChar) - if isBarbarianOfLevelSixOrHigher(nodeChar) and hasAspectOfTheBeastBear(nodeChar) then + if isBarbarianOfLevelSixOrHigher(nodeChar) and + hasAspectOfTheBeastBear(nodeChar) then mult = mult * 2 end From 5d0d9b22d74f5080193d639e0ba7e9a6d6e0fdad Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Thu, 10 Feb 2022 00:27:16 -0700 Subject: [PATCH 3/7] Formatting. --- scripts/aspect_of_the_beast_bear.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/aspect_of_the_beast_bear.lua b/scripts/aspect_of_the_beast_bear.lua index 7780da2..d7a89dc 100644 --- a/scripts/aspect_of_the_beast_bear.lua +++ b/scripts/aspect_of_the_beast_bear.lua @@ -59,7 +59,9 @@ function updateInventoryPaneEncumbranceBaseIfLoaded(w) and w.inventory.subwindow.contents and w.inventory.subwindow.contents.subwindow and w.inventory.subwindow.contents.subwindow.encumbrancebase - and w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated) then return end + and w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated) then + return + end -- See: w.inventory.subwindow.contents.subwindow.encumbrancebase.onTraitsUpdated() From 2555eccceef3e5360d761d2813506ae089234e40 Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Sun, 13 Feb 2022 13:54:54 -0700 Subject: [PATCH 4/7] announce --- extension.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension.xml b/extension.xml index cb10844..41aab68 100644 --- a/extension.xml +++ b/extension.xml @@ -1,9 +1,9 @@ - + Feature: Aspect of the Beast - Bear - 1.1 + 1.1.1 998 Justin Freitas Double encumbrance limits if character is a barbarian of level six or higher and has Aspect of the Beast: Bear in their Features. From 74be0bfc2b5b0e58c1a59cca65f178704fbc12e3 Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Sun, 20 Feb 2022 14:47:34 -0700 Subject: [PATCH 5/7] Fit on line. --- extension.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.xml b/extension.xml index 41aab68..ab0e7c5 100644 --- a/extension.xml +++ b/extension.xml @@ -1,6 +1,6 @@ - + Feature: Aspect of the Beast - Bear 1.1.1 From f37c56407623e41b6aabb56f6748d7d9c5901d0c Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Sun, 20 Feb 2022 14:59:29 -0700 Subject: [PATCH 6/7] Announce text. --- extension.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.xml b/extension.xml index ab0e7c5..33cd590 100644 --- a/extension.xml +++ b/extension.xml @@ -1,6 +1,6 @@ - + Feature: Aspect of the Beast - Bear 1.1.1 From 0d2b590031f093c7fd6303ec479648ecfbf43227 Mon Sep 17 00:00:00 2001 From: JustinFreitas Date: Tue, 15 Mar 2022 19:33:48 -0600 Subject: [PATCH 7/7] v1.2 - Work with FGU 4.1.14+ --- README.md | 5 +++-- extension.xml | 4 ++-- scripts/aspect_of_the_beast_bear.lua | 20 ++++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e06366..d562da9 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ https://github.com/JustinFreitas/AspectOfTheBeastBear -Aspect Of The Beast: Bear v1.1, by Justin Freitas +Aspect Of The Beast: Bear v1.2, by Justin Freitas ReadMe and Usage Notes -The purpose of this Fantasy Grounds 5e extension is to apply an additional 2x multiplier to encumbrance limits to barbarians of level 6 or higher that have the Aspect of the Beast: Bear listed in their features. The 'Bear' designation can be separated from the main feature with a dash or colon (i.e. - or :). Any amount of white space is also fine as it's matched via a flexible regular expression. +The purpose of this Fantasy Grounds 5e extension is to apply an additional 2x multiplier to encumbrance limits to barbarians of level 6 or higher that have the Aspect of the Beast: Bear listed in their features. The 'Bear' designation can be separated from the main feature with a dash or colon (i.e. - or :). Any amount of white space is also fine as it's matched via a flexible regular expression. Note, that if the client is FGU of 4.1.14 or greater, this functionality is built in and works off of 'Aspect of the Bear' by default, so the extension will be smart and not double up the bonus a second time if both are found. Future Enhancements: - Have the barbarian class and level filtering be an option instead of always enabled, defaulting to enabled. @@ -14,3 +14,4 @@ Future Enhancements: Changelist: - v1.0 - Initial version. - v1.1 - Improvements to conform to FGU and upcoming standards. Improvements in code structure. Matching/regex improvements for flexibility and reliability. Function renaming for clarity. +- v1.2 - Fixed the extension to work with the FGU 4.1.14+ Aspect of the Bear functionality and not double the bonus a second time. diff --git a/extension.xml b/extension.xml index 33cd590..56388ec 100644 --- a/extension.xml +++ b/extension.xml @@ -1,9 +1,9 @@ - + Feature: Aspect of the Beast - Bear - 1.1.1 + 1.2 998 Justin Freitas Double encumbrance limits if character is a barbarian of level six or higher and has Aspect of the Beast: Bear in their Features. diff --git a/scripts/aspect_of_the_beast_bear.lua b/scripts/aspect_of_the_beast_bear.lua index d7a89dc..8e10f08 100644 --- a/scripts/aspect_of_the_beast_bear.lua +++ b/scripts/aspect_of_the_beast_bear.lua @@ -1,4 +1,5 @@ local getEncumbranceMult_orig +local bBearFromFGU function onInit() getEncumbranceMult_orig = CharManager.getEncumbranceMult @@ -7,6 +8,12 @@ function onInit() local featureNamePath = "charsheet.*.featurelist.*.name" DB.addHandler(featureNamePath, "onAdd", onFeatureNameAddOrUpdate) DB.addHandler(featureNamePath, "onUpdate", onFeatureNameAddOrUpdate) + bBearFromFGU = checkBearFromFGU() +end + +function checkBearFromFGU() + local nMajor, nMinor, nPatch = Interface.getVersion() + return nMajor >= 4 and nMinor >= 1 and nPatch >= 14 end -- This is entered on strength change or trait change (not feature) @@ -15,22 +22,27 @@ end function getEncumbranceMultOverride(nodeChar) local mult = getEncumbranceMult_orig(nodeChar) if isBarbarianOfLevelSixOrHigher(nodeChar) and - hasAspectOfTheBeastBear(nodeChar) then + hasAspectOfTheBeastBearIndependentOfFGU(nodeChar) then mult = mult * 2 end return mult end -function hasAspectOfTheBeastBear(nodeChar) +function hasAspectOfTheBeastBearIndependentOfFGU(nodeChar) + local bBear, bBeastBear for _, nodeFeature in pairs(DB.getChildren(nodeChar, "featurelist")) do local name = DB.getValue(nodeFeature, "name", ""):lower() if string.match(name, "^%W*aspect%W+of%W+the%W+beast%W*bear%W*$") then - return true + bBeastBear = true; + elseif string.match(name, "^%W*aspect%W+of%W+the%W+bear%W*$") then + bBear = true; end end - return false + return (bBear and not bBearFromFGU) or + (bBeastBear and not bBearFromFGU) or + (bBeastBear and not bBear and bBearFromFGU) end function isBarbarianOfLevelSixOrHigher(nodeChar)