Jump to content

[LE] I'm having a problem with a mod I made. Over time, it has put 15000 scripts into my save file.


monsto

Recommended Posts

I made a mod (unpublished) that updates Portable OnDemand Disposable Unlimited Mannequins. Basically, it's a mannequin mod where you put down actual NPCs, they wear the equipment you give them, and then since they're NPC you can pose and animate them.


I rewrote it from scratch, using a decompiled version of the original as reference. I added a list menu (like Add Item Menu) and a kinda plugin system where you can drop in an ESP with new mannequins and it will add them to the list.


The problem is that I didn't realize that there's A TON of forms/scripts attached to each, and I have no idea where they came from. Based on my tests, it seems to be > 30 forms/scripts per mannequin. And then deleting the mannequin, it doesn't clean up the scripts. A recent save game viewed in Savetool shows that there's > 15k forms/scripts attached to the cell that I use, and there are no orphans. Skyrim.esm only has ~8800 . . . so obviously this is a problem.


I believe this is at the core of the in-game problem I'm having which is that the game hangs when loading the most recent save as the first load from starting the game. I can first-load a previous save to start the game, then load the save that hangs, and the game works just fine.


Anyway, I now know that disabling and removing the mannequin doesn't detach and kill/clean up the scripts. So I need to do that.


The game doesn't really do a whole lot of spawn/destroy of entities with scripts attached to them. Even if it did, it wouldn't do it hundreds of times in a single cell. so I realize that this kinda cleanup may not even be a thing.


I also realize that the better practice would be to not attach the scripts in the first place, but I have no idea where they came from. I purposefully only attached I think like 5 (it's been a while), so filtering out unknowns will be "hard". It seems easier to clean up properly on deletion, which would be a good thing to do regardless of reduced attachments.


So I realize that any specific help would be based on seeing the source, but right now I really just need to know if this kind of clean up is possible, and how it might be done.


Link to comment
Share on other sites

How much have you had to make "clean saves" while working on your mod?

 

If a mannequin has 5 scripts attached and loaded into memory when you make a save, exit the game, deactivate the mod, enter the game, save the game without the mod, update the mod, reactivate the mod and load the game again... the game will load in new instances of the 5 scripts. Repeat this process over and over and you'll eventually hit 15000 instances of the same 5 scripts.

 

Try testing on a completely fresh game and see if the script count increases beyond the number of instances necessary for your modified SPODUM mannequins.

Link to comment
Share on other sites

How much have you had to make "clean saves" while working on your mod?

 

If a mannequin has 5 scripts attached and loaded into memory when you make a save, exit the game, deactivate the mod, enter the game, save the game without the mod, update the mod, reactivate the mod and load the game again... the game will load in new instances of the 5 scripts. Repeat this process over and over and you'll eventually hit 15000 instances of the same 5 scripts.

 

Try testing on a completely fresh game and see if the script count increases beyond the number of instances necessary for your modified SPODUM mannequins.

 

I tested it with 2 saves.

 

Used savetool to delete all forms.

Dropped a mannequin, saved First.

Deleted the mannequin, saved Second.

 

Savetool showed 33 forms on the 2nd save.

 

I haven't work on it in a while, so the quit/load thing didn't affect all this. Also, you can load a save to get fresh script when the mod isn't part of the save. I had a small box cell that I was testing in. So quickload the save that hasn't had the mod, I get my notification that the script has loaded, and I can see the effects without having to completely cycle the game. Tremendous time saver that also wouldn't pile up the scripts/forms.

 

I've had this happen several times over a couple years, but only after a cell has a bunch of mannequins in it, after months of toodling.

 

If there's a method to purging scripts and forms and etc from memory when the entity it's attached to is removed from the visibility of the game (I can't really call it 'deleting' anymore) that's what I need to do.

Link to comment
Share on other sites

I want to reflect to this older forum thread https://forums.nexusmods.com/index.php?/topic/7832768-i-have-a-script-that-works-fine-most-of-the-time-on-the-4th-use-the-script-stops-cold-source-gist-included/?hl=+monsto

You wrote there: "it's working right now and I'm reluctant to mess with it."

 

You write now: "I rewrote it from scratch, using a decompiled version of the original as reference." "I didn't realize that there's A TON of forms/scripts attached to each, and I have no idea where they came from."

 

That is the question! Where does it (forms and scripts) come from?

mabye OnInit() I do not know which script(s) you are using.

Edited by ReDragon2013
Link to comment
Share on other sites

Well, in the CK you can look at the mannequins added by the mod and see which scripts are attached, then decompile them. I found out with working on my Solar Street Lights mod for FO4, that there are things you need to do for object references to actually be deleted.

 

1. If the object reference has any scripts that have registered events, you must unregister them before deleting.

2. You must clear any held object references in the script by setting them to none.

3. If the object reference is set as a property in another active script, or the object reference set to a reference alias, it won't be deleted.

 

Hope that helps.

Link to comment
Share on other sites

@ dylbill


"3. If the object reference is set as a property in another active script, or the object reference set to a reference alias, it won't be deleted."

This i didn't know...!, i have on the current thing i'm working 3 trigger boxes that are used as buttons and they are set as property in 2 sub scripts and they are finally used by the 'Master Controller', the 'Master Controller' has also the job to delete all of those reference that won't be used anymore after the whole 'constraction scene' is over.


Not deleting those 3 buttons is not a big deal, afterall they are just 3 buttons..., but do you know any workaround for this?.


Thank you very much in advance.

Link to comment
Share on other sites

 

@ dylbill
"3. If the object reference is set as a property in another active script, or the object reference set to a reference alias, it won't be deleted."
This i didn't know...!, i have on the current thing i'm working 3 trigger boxes that are used as buttons and they are set as property in 2 sub scripts and they are finally used by the 'Master Controller', the 'Master Controller' has also the job to delete all of those reference that won't be used anymore after the whole 'constraction scene' is over.
Not deleting those 3 buttons is not a big deal, afterall they are just 3 buttons..., but do you know any workaround for this?.
Thank you very much in advance.

 

 

You just need to set those properties in the sub scripts, and the master script to None after deleting. Having them as current properties in active scripts makes them persistent.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...