the Sim Settlements forums!

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Can I get some help on overwriting a function by extending a script?

cbrgamer2

Well-Known Member
Messages
723
Hi,
I'm thinking @msalaba might be able to help me here, but I've put this public in case anybody else knows.
I'm trying to test something in the ResouceManager.pex script in the latest build. To do this, I'm trying to overwrite a function. Here is the script I'm using :
1624678713611.png
I have attached the script to the SS2_ResourceManager quest (using another esp) and used FO4Edit to attached the properties. For some reasons some properties are still not filled. I've left them, as I don't think that is the problem (since I'm not using any of the properties anyway). In game, I can call cqf SS2_ResourceManger "ResourceManagerExtend.TestThis" and the "Testing This" debug box correctly pops up.
The AdjustNonPlotMaintenanceCostsOnSettlement function is called when the OnWorkshopObjectPlaced event is called (along with others) and I'm trying to see when and how often it is called. When I place a power generator, I can see through my other debug tools the non-plot costs have been changed, so I believe the function is being called properly in the SS2 script (in that instance), but my override is not working.
Since I'm working with a decompiled script, I'm wondering if the function name or parameters are not the same? Earlier I was able to override one of the functions in the HudResources script so when the InfoBox popped up it ran my code instead. I used this to work out why the InfoBox values were wrong.
 
When defining an extended function in a child script, the definition must match the parent. I assume that because you didn't define abRemove = false, the child function isn't being called. I also assume if you used the default compiler, it would have given you a compile error.
Copy this exactly:
Function AdjustNonPlotMaintenanceCostsOnSettlement(ObjectReference akWorkshopObjectRef, WorkshopScript akWorkshopRef, Bool abRemove = false)
Edit: I had a compile error extending DisableNoWait It was kinda funny... :todd:
Code:
; parent
Function DisableNoWait(abFadeOut = false)
; child
Function DisableNoWait(abFadeOut = False)
I have gotten into the habit of just copying the definition from the parent script.
 
Last edited:
LOL, it took me some serious head scratching! :todd:
 
Okay, so I've now had that experience as well - it didn't work when I copied the function name from the decompiled parent script because it had bool instead of Bool ... I've got it now
 
@msalaba can you please tell me the full function name (and parameters etc) in the source for the latest patch for me? My extension is not working again and when I had a look at the decompiled script it no longer seems to have the = false for abRemove. I've tried several different possibilities, but I just can't get it to work.
 
@cbrgamer2
Function AdjustNonPlotMaintenanceCostsOnSettlement(ObjectReference akWorkshopObjectRef, WorkshopScript akWorkshopRef, Bool abRemove = false)
This is the function definition from the latest source.
 
Hmmm ... I can't get it to work. Oh well, I may have to give up trying to help finding out why non-plot maintenance costs do not go down when a workshop item is removed. I have done some tests that I believe rule out script lag. This is an issue that has been reported by others, so I think it's important to investigate it if we want the resources part of the mod working properly.
 
Like I said before, if you want something compiled, send me a DM. ;)
 
Top