-
March 23rd, 2020, 20:58 #1
- Join Date
- Mar 2020
- Posts
- 4
Replacing Functions Without Package Name
I want to replace the onCarriedChanged which is in a ruletset (eg 3.5e) with an extension, but the function doesn't have a package name associated with it (eg CharManager.onCarriedChanged). How can I have my extension overwrite the 3.5e onCarriedChanged (which itself is overwriting the CoreRPG onCarriedChanged function)?
At the moment I keep running into an error where it either says window is nil, or getDatabaseNode is nil and it definitely can't reach the 3.5e onEncumbranceChanged because that also doesn't have a package name. Is it possible to do this in an extension - to replace these types of function via extension without having to change the rulesets?
I am using FG Classic if that helps.
I appreciate any information people can provide!
-
March 23rd, 2020, 21:49 #2
- Join Date
- Jun 2013
- Location
- Isanti, MN
- Posts
- 2,922
It's called via an update handler.
./campaign/scripts/char_invlist.lua: DB.addHandler(DB.getPath(node, "*.carried"), "onUpdate", onCarriedChanged);
./campaign/scripts/char_invlist.lua: DB.removeHandler(DB.getPath(node, "*.carried"), "onUpdate", onCarriedChanged);
-
March 28th, 2020, 08:57 #3
- Join Date
- Mar 2020
- Posts
- 4
-
March 28th, 2020, 13:19 #4
- Join Date
- Jun 2013
- Location
- Isanti, MN
- Posts
- 2,922
Err, calling the addHandler should replace the current handler. Either that or call both (I haven't tested, and the documentation is unclear on this point, but pretty sure it replaces the current handler.) The handler function is called everytime that database field is changed - you know what handler functions are, right?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks