LeahTheUnknown Posted April 13, 2018 Share Posted April 13, 2018 (edited) I want to write a script for FO4Edit, but I haven't used PASCAL since high school, some twenty years ago. What I want is simple, albeit not easy. I need the script to go through the vanilla assets, then my assets, with which I have replaced the vanilla assets (using the same mesh), and copy the Material data to my assets. In the original incarnation of Commonwealth Cleanup, I simply used the Creation Kit's "Search and Replace" function. That replaces the vanilla statics/whatever with my activator versions, but does not copy the Material data (obviously) for the individual references. (And don't worry, I know about PreCombines. I will be making new PreCombines for the new version. Hopefully, I'll be able to shrink the files size so I can upload it to Nexus.) I copied the script that restores names from master records and tweaked it, I just need someone to check it. I don't want to royally screw up my mod. unit UserScript; function Process(e: IInterface): integer; var m: IInterface; begin if not ElementExists(e, 'XMSP') then Exit; // get master record m := Master(e); // no master - nothing to restore if not Assigned(m) then Exit; // if record overrides several masters, then get the last one // I don't know what this does. ~GKX if OverrideCount(m) > 1 then m := OverrideByIndex(m, OverrideCount(m) - 2); if not SameText(GetElementEditValues(e, 'XMSP'), GetElementEditValues(m, 'XMSP')) then SetElementEditValues(e, 'XMSP', GetElementEditValues(m, 'XMSP')); end; end. Thanks in advance ~GKX EDIT: Aaaand I just realized this isn't going to work because the originals are mostly Statics, and my records are Activators. However, my activators have the exact name as the statics, just with _act_ tacked on the front, so hopefully this is still doable. Edited April 13, 2018 by GenghisKhanX Link to comment Share on other sites More sharing options...
pra Posted April 13, 2018 Share Posted April 13, 2018 Fo4Edit won't screw your mod until you hit save. And even then it should make backups somewhere. And even if not, you can just backup your own ESP manually.It will even highlight the records as bold which it modified. Messing around and just running the script to see what happens is a perfectly legitimate way of building scripts like this. The script looks fine to me, though. If your records aren't actually overriding anything, but are supposed to replace statics, try using MainRecordByEditorID to get the static after stripping off the _act_ substring. See also:https://www.creationkit.com/index.php?title=TES5Edit_Scripting_FunctionsThis documentation is lacking, but it helps. It also helps to search for a specific function within the scripts which come with Fo4Edit to see how they are used. Link to comment Share on other sites More sharing options...
LeahTheUnknown Posted April 13, 2018 Author Share Posted April 13, 2018 Turns out the statics are the master records for my activators. So it got a lot simpler. I just switched around a few things, like checking if the master has an XMSP record rather than the replacement. We'll see how it goes. Thanks for responding! ~GKX Link to comment Share on other sites More sharing options...
Recommended Posts