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

    Overriding CoreRPG functions

    Morning All,

    Been working on the Party Sheet this morning and one thing I need to get to grips with in CoreRPG is overriding functions.

    For example, CoreRPG has a function called 'buildPartyCoins'. That's perfect, but it's based on a list of coins that Traveller doesn't have, so I want to repoint it towards a single node within the character sheet.

    So how do I tell my ruleset to override just that function?

    I've tried adding it into my code, but the CoreRPG function always runs, and I'd rather not copy the entire 'ps_manager_loot.lua', incase CoreRPG gets any updates in this area (inventory etc).

    Thanks,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  2. #2

    Join Date
    Jul 2010
    Location
    Germany, Frankfurt
    Posts
    156
    You could try to do it like this:

    Add a own manager for replacing global functions to your base.xml or extension.xml:

    <script name="replaceFuncManager" file="scripts/manager_func_replace.lua" />

    To replace a function do something like this in you replace manager script:


    local oldRef;

    function onInit()
    -- save the old ref, maybe you need it
    oldRef = PartyLootManager.buildPartyCoins;

    -- replace the function reference with you own one
    PartyLootManager.buildPartyCoins = buildPartyCoinsReplace;
    end

    function buildPartyCoinsReplace()
    -- your own code
    -- you could still execute the "old" function by the oldRef , if you need to (if the old function calls other global function within the same script, you have to wrap them all in you manager also)
    ...
    ...
    end

  3. #3
    Quote Originally Posted by drvolk View Post
    You could try to do it like this:

    Add a own manager for replacing global functions to your base.xml or extension.xml:

    <script name="replaceFuncManager" file="scripts/manager_func_replace.lua" />

    To replace a function do something like this in you replace manager script:


    local oldRef;

    function onInit()
    -- save the old ref, maybe you need it
    oldRef = PartyLootManager.buildPartyCoins;

    -- replace the function reference with you own one
    PartyLootManager.buildPartyCoins = buildPartyCoinsReplace;
    end

    function buildPartyCoinsReplace()
    -- your own code
    -- you could still execute the "old" function by the oldRef , if you need to (if the old function calls other global function within the same script, you have to wrap them all in you manager also)
    ...
    ...
    end
    That sounds perfect, thanks for making the time to answer this!

    Cheers,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  4. #4
    And it worked a treat!

    Ace, thanks very much I can now override the splitting of coins over the party.

    Cheers,
    MBM
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  5. #5

    Join Date
    Jul 2010
    Location
    Germany, Frankfurt
    Posts
    156
    Gladly, especially if the development of your great ruleset could be helped a little bit

  6. #6
    Quote Originally Posted by drvolk View Post
    Gladly, especially if the development of your great ruleset could be helped a little bit
    This is one of the reasons I love FG so much, the community really is superb, and I love learning new stuff every day even though I'm an old hand when it comes to coding!

    The ruleset is pretty much there, this is something one of the testers found. I can't wait to get into all the new Starship stuff once the SFRPG has it all finished!
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  7. #7
    Why not just update the game system coins that the function is expecting? You need to do that for the other currency functions anyway (parcel, party sheet, etc).

    JPG

  8. #8
    Quote Originally Posted by Moon Wizard View Post
    Why not just update the game system coins that the function is expecting? You need to do that for the other currency functions anyway (parcel, party sheet, etc).

    JPG
    Traveller has the universal 'Credit' but Cash on Hand is the one that's affected by normal transactions. It's not in a list of currencies as such, still it's all done and I learned how to override things which is important I think.

    Cheers
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  9. #9

    Join Date
    Jan 2015
    Location
    Grand Rapids, MI
    Posts
    136
    From what I understand I can do this when loading my scripts with extension.xml. Can I do the replace function on a per-control basis as well? Can I just change my lua on say onHealthChanged for a single box or other instances like that?

  10. #10
    Are you just trying to add a new coin type? like CRD where normally it uses GP?
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

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
  •  
STAR TREK 2d20

Log in

Log in