FG Spreadshirt Swag
  1. #1

    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!

  2. #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);

  3. #3
    Quote Originally Posted by Andraax View Post
    It's called via an update handler.
    Thank you, I can see where it's called, but it seems like you can't overwrite these types of functions. Easiest way appears to be to replace the button itself by adding script to run additional functions.

  4. #4

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,922
    Quote Originally Posted by O11 View Post
    Thank you, I can see where it's called, but it seems like you can't overwrite these types of functions. Easiest way appears to be to replace the button itself by adding script to run additional functions.
    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

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