Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    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:
    Attached Images Attached Images

  2. #2
    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,
    JPG
    Last edited by Moon Wizard; February 26th, 2023 at 07:15.

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    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.

    Regards,
    JPG
    Could you please create a character, add any spell to char sheet, switch to "combat" view? The spell group captions should disappear (as in my screenshots).
    This means that some functionality is disabled by this...

  4. #4
    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

  5. #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):

  6. #6
    Quote Originally Posted by Moon Wizard View Post
    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
    @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.

  7. #7
    What do you mean "spell level captions"?
    Can you circle an example of a "spell level caption"?

    JPG

  8. #8
    Quote Originally Posted by Moon Wizard View Post
    What do you mean "spell level captions"?
    Can you circle an example of a "spell level caption"?

    JPG
    Here you go:
    Attached Images Attached Images

  9. #9
    Quote Originally Posted by xelab View Post
    @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.
    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):

  10. #10
    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
    Attached Images Attached Images

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