Thread: Overriding CoreRPG functions
-
May 2nd, 2018, 09:36 #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,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
May 2nd, 2018, 10:10 #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
-
May 2nd, 2018, 10:13 #3Ruleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
May 2nd, 2018, 10:33 #4
And it worked a treat!
Ace, thanks very much I can now override the splitting of coins over the party.
Cheers,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
May 2nd, 2018, 11:39 #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
-
May 2nd, 2018, 11:46 #6
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!
-
May 3rd, 2018, 05:08 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,566
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
-
May 3rd, 2018, 09:13 #8Ruleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
June 1st, 2018, 16:33 #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?
-
June 1st, 2018, 16:44 #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