5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096

    Extension Question

    It has been a while since I wrote an extension, and I just need to check because I cannot locate it in the developer documentation:

    If I override a manager routine in my extension lua include file, that code will replace the code in the manager, right? And there is no way to invoke the original code (using super or some such) if I just want to intercept the call, check some parameters, and pass control back to the original unless it meets some very specific parameter criteria, right?

  2. #2
    Yeap, unlike with the XML templates, lua functions cannot be "supered" from an Extension back to a Ruleset - the whole lua file needs to be reproduced (with appropriate changes) in the Extension

    Does that answer you question?

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  3. #3

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    That's what I thought, Dulux, but if you need to replace a routine in a manager (in this case, the Table.Manager), do I need to replace each routine in there, or just the ones I need to replace? Since a manager is accessed through Table.xxxx, where xxxx is the name of the routine, how do I even replace it? My guess is that I have to override the entire Manager declaration in my xml so that "Manager" refers to my file and not the original file. So, I think I have to redirect the Table manager in my own xml declaration and duplicate the entire Table.Manager file just to change a couple of lines within one routine. Can you confirm?

  4. #4
    Yes, that's pretty much what you have to do.

    I suspect that's one reason why there are so many small (<50 lines) lua files - so that they can be "swapped out" easier than if there was only a few big ones.
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  5. #5
    Actually, I think that there have been a few extensions that have successfully replaced individual functions within a ruleset. As long as the functions are not defined as local (which none are), then you should be able to replace them. The only caveat is that you still need to be watchful of code updates in the base code, and cross-extension clashes.

    Code:
    function onInit()
      TableManager.performRoll = newPerformRoll;
    end
    
    function newPerformRoll(...)
      ...
    end
    Regards,
    JPG

  6. #6
    Now that's an interesting idea - and it'll cut down on the code-size as well - hmmmmm?!

    That's for that Moon
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  7. #7

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Quote Originally Posted by Moon Wizard View Post
    Actually, I think that there have been a few extensions that have successfully replaced individual functions within a ruleset. As long as the functions are not defined as local (which none are), then you should be able to replace them. The only caveat is that you still need to be watchful of code updates in the base code, and cross-extension clashes.

    ....

    Regards,
    JPG
    Thanks, MW. It really doesn't make much difference, because you still have to be mindful if you copy the whole file. In fact, it may be less likely that one routine is affected in a change than anything in a whole file. That override trick you mentioned: I never would have come up with that without your input. Muchas gracias, my friend!

  8. #8

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,922
    If you just need a wrapper around the original code, save off the current routine and call it. This emulates a call to a base class function. This way you'll get changes in the underlying code as well...

    Code:
    function onInit()
      originalRoll = TableManager.performRoll;
      TableManager.performRoll = newPerformRoll;
    end
    
    function newPerformRoll(...)
      ...
      originalRoll(...);
      ...
    end
    (Code has not been tested, but *should* work... :-D )

  9. #9
    You realize now I've got to go back through all my code and redo it all, don't you?!
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  10. #10
    Quote Originally Posted by dulux-oz View Post
    You realize now I've got to go back through all my code and redo it all, don't you?!
    You realize now that you have to figure out the best way to do this and make a tutorial video for the rest of us.
    I never claimed to be sane. Besides, it's more fun this way.

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