Thread: Gracefully override a function
-
February 25th, 2023, 19:24 #1
- Join Date
- Aug 2020
- Posts
- 94
Gracefully override a function
Hi all,
I am trying to gracefully override a function in 5E/campaign/record_power.xml.
I follow the advice of @Trenloe (link) and @SilentRuin(link), but I still do not get expected behavior.
Here is my code:
Code:<root> <!-- campaign/record_power.xml --> <windowclass name="power_page" merge="join"> <script> function onInit() if super and super.onInit then super.onInit(); end end function updatePowerWindowUses(nodeChar, w) super.updatePowerWindowUses(nodeChar, w); -- call old function Debug.chat("works") end </script> </windowclass> </root>
I expect this code to have no effect except for printing "works" in chat, however, it disables some character sheet functionality, namely removing spell group titles.
What could be the reason for this?
Here is how char sheet looked before the change:
And this is how it looks after:
-
February 25th, 2023, 19:59 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,554
I just built a basic extension using your example, selected a 5E campaign, selected the extension, loaded campaign, then opened character sheet actions tab. It was working for me.
Sample extension is attached.
EDIT: Removed sample extension; see later posts for updated version.
Regards,
JPGLast edited by Moon Wizard; February 26th, 2023 at 07:15.
-
February 25th, 2023, 20:50 #3
- Join Date
- Aug 2020
- Posts
- 94
-
February 25th, 2023, 21:20 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,554
The example code you posted doesn't do anything like that, just spits on a message when initializing and when uses changed (slots, etc.)
Regards,
JPG
-
February 25th, 2023, 21:31 #5
I would add that I try to do all my overrides in my manager if not XML scripting. As your example is overriding XML scripting - that can get tricky if everything in the XML script your overriding is not defined just right especially if its got globals its accessing.
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
February 25th, 2023, 21:42 #6
- Join Date
- Aug 2020
- Posts
- 94
@Moon Wizard:
That is precisely my point, the script SHOULD NOT do anything like that, it should just spit out a message, but it DOES remove spell-level captions in "Combat" mode.
Could you please check my screenshots again and try switching to "combat" mode on the character with the extension enabled?
I this behavior not reproduced on your end?
I am on the newest patch of the FGU.
@SilentRuin: What do you mean in your "manager"? Do you mean in the .lua file that is associated with the windowclass? In that case, I do get the same results as in the above.Last edited by xelab; February 25th, 2023 at 21:58.
-
February 25th, 2023, 21:58 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,554
What do you mean "spell level captions"?
Can you circle an example of a "spell level caption"?
JPG
-
February 25th, 2023, 22:10 #8
-
February 26th, 2023, 04:41 #9
I mean a named lua in the extension.xml vs any script defined directly in a windowclass or template xml file (in lua or not). They are not the same. Things that are named have all the data referenced right there and can be overriden and not worry about any super function accessing external data to that function or things externally calling it. In the non named ones they have to be defined perfectly in order to have it called in the super or reference any external data or it simply wipes it out with your local copy of it and if you don't override every single thing that touches it or it accesses in that super script then all the things that call it or access things externally to that super override will not happen. Unless the script your overriding (not just the function) have the self and all that perfectly defined. Most don't.
Last edited by SilentRuin; February 26th, 2023 at 04:49.
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
February 26th, 2023, 05:46 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,554
Are you sure that you don't have an unpacked CoreRPG or 5E ruleset in your FG data folder?
I'm not seeing that issue with the extension I posted above. (See image.)
EDIT: Hold on, just remembered you mentioned "Combat" mode and seeing something different though not specifically what you saw. Investigating.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks