-
July 7th, 2020, 23:41 #1
Unity: getValue called by handler returns previous value
I noticed that my Total Encumbrance extension isn't quite behaving itself in FGU.
I have this line in onInit:
Code:DB.addHandler(DB.getPath('charsheet.*.inventorylist.*.carried'), 'onUpdate', applyPenalties)
Code:local total = DB.getValue(nodeChar, 'encumbrance.total', 0)
Is there a simple alternative that will return the value after clicking on both systems?
Pathfinder ruleset.Last edited by bmos; July 9th, 2020 at 12:39.
bmos' extensions
he/them
-
July 12th, 2020, 04:26 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,566
I think that the problem you're running into is that there is no guarantee of handler trigger order, partially because Lua handler triggers are implemented in Lua (at least in FGC) and have no inherent order.
Have you thought about triggering the applyPenalties when "chatsheet.*.encumbrance.load" is updated instead?
Regards,
JPG
-
July 12th, 2020, 16:14 #3bmos' extensions
he/them
-
July 12th, 2020, 18:02 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,566
Perhaps you can break up the part of the code tied to the total encumbrance updates from the carried updates?
JPG
-
July 12th, 2020, 19:34 #5bmos' extensions
he/them
-
July 23rd, 2020, 10:54 #6
disregard
Last edited by bmos; July 23rd, 2020 at 11:08.
bmos' extensions
he/them
-
July 23rd, 2020, 11:12 #7
Unfortunately, after changing the code, it's still behaving the same.
This has brought me to a realization:
It's not because of the handlers
Instead of a handler, I added a script tag to the carried button's xml which should get around any handler-timing unpredictability.
It sees the "carried" value change, but the total carried lags behind the carried state.
I guess this means that the code to add-up inventory weight is running after my script in FGU but not FGC.
I'm working around it by adding the same trigger script tag to charsheet.*.encumbrance.load for the time being as you suggested.
Is there a way to check if the user is using unity? Some sort of version check function?Last edited by bmos; July 23rd, 2020 at 11:47.
bmos' extensions
he/them
-
July 23rd, 2020, 12:07 #8
There are two ways to check for versioning that I can think of using.
You can check if a windowclass should be used by placing a version=">=4" in the tag. Example:
<windowclass name="imagewindow" version=">=4">
For lua, you can do an if/then statement to check for version. An Example:
if Interface.getVersion() >= 4 then
This of course works for checking for FGC by using the inverse of the code I presented.Dominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
-
July 23rd, 2020, 13:12 #9
thanks!
bmos' extensions
he/them
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks