PDA

View Full Version : CharEncumbranceManager.addCustomCalc Message



LordEntrails
August 23rd, 2025, 03:26
I'm trying to resolve a message that shows up in chat when opening the inventory tab of the charactersheet in my ruleset. The full message is:

CharEncumbranceManager.addCustomCalc must be called in global script onInit function.

This comes from CoreRPG manager_char_encumbrance.lua
I've tried adding the command to my charsheet_inventory onInit call, but it doesn't resolve.

How do I resolve this? Where should I add the call?

edit: this might help, but not sure; https://www.fantasygrounds.com/forums/showthread.php?72555-Developer-Notes-2022-02-Ruleset-Updates&p=639600&viewfull=1#post639600

Moon Wizard
August 23rd, 2025, 17:46
It has to be defined in a global script (i.e. CharManager, ActionInit, and so on). It can't be defined in a windowclass or windowcontrol script.

Regards,
JPG

LordEntrails
August 23rd, 2025, 18:16
So I don't have any of those in my ruleset. I tried creating global_scripts.lua and that didn't work. I then added it to my dataLibrary.lua (where all my records are defined) and that didn't work.

This is the code I put in glaobe_scripts.lua

function onInit()
CharEncumbranceManager.addCustomCalc();
end

What am I missing?

Trenloe
August 23rd, 2025, 20:59
If you look at the function definition for CharEncumbranceManager.addCustomCalc its argument is fnEncumbranceCalc - which needs to be a function that will be used for the custom calculation.

Moon Wizard
August 23rd, 2025, 22:32
If you use CharEncumbranceManager.addStandardCalc, it will call CharEncumbranceManager.addCustomCalc with the standard weight calculation built into CoreRPG.

Regards,
JPG

LordEntrails
August 23rd, 2025, 23:02
Thanks all, with Moon and Dom's help on Discord we figured this out. All I had to do was pull the legacy code from the charsheet_inventory class that I had defined (3 years ago). Errors cleared up and encumbrance is working as expected. Thanks for the help :)