Hi fellow modders, I'm MilletGtR, the creator of iActivate on the Nexus.
I've just recently gotten into the world of pascal scripting, so please forgive me if my quesions have obvious answers :) I'll get right into my issue.
In iActivate, I have altered some of the game setting strings to hide the Activate text, such as "Open", "Talk" and "Search". The problem there is that some items in the world of Skyrim have an "Activate Text Override" defined, meaning it overwrites the game setting (Open, Search, Talk and so on). Initially I had the ambition to edit all of these objects by hand, to be included in the mods .esp, but that took a stop when I realized that it would require patch after patch to be compatible with some of the more popular mods out there.
Instead I decided to learn Pascal and create a script in TES5Edit that people can run and make their own patch for their own load order. I've now created a fully functional script which finds all relevant records which contains the element 'RNAM' (which is the code for Activate Text Override), copies them to a new file, and at the same time removes the string attatched to 'RNAM'.
Now I've come to my issue: The script works very well on small .esp's, but the bigger the plugin file, the longer it takes per record copied. It seems to be exponential.
Down below is my complete script. Due to my research I suspect that the culprit is the wbCopyElementToFile function, which to me seems to scan the entire record every single time the procedure is run.
Quote
{ Creates a patch for iActivate that selects all relevant records containing the element 'RNAM' or "Activate Text Override", and modifies them to remove the string that is defined in 'RNAM'. } unit UserScript;
var iAFile: IInterface; RNAMList: TStringList; recs: array [0..50000] of IInterface;
function Initialize: integer; var i: Integer;
begin i := MessageDlg('Before running this script, you should be aware that:'+chr(13)+'1. You need to select all plugins that you wish to apply this script to, before running the script.'+chr(13)+'2. If you create this patch and later remove any of its master plugins you selected in step 1, you need delete the previously created patch, and create a new patch with this script, or the game will crash on startup.'+chr(13)+'3. This may take a while to process, so be patient.'+chr(13)+''+chr(13)+'Are you sure you wish to continue?', mtConfirmation, [mbYes, mbCancel], 0); if i = mrYes then begin RNAMList := TStringList.Create; AddMessage('Building RNAM list, please stand by..'); end else begin Result := 1; Exit; end; end;
function Process(e: IInterface): integer; var ID: integer; s: string; begin //Ignores all signatures except the ones below. if (Signature(e) 'ACTI') and (Signature(e) 'CONT') and (Signature(e) 'FLOR') and (Signature(e) 'FURN') then Exit; //If the searched record does not contain the element 'RNAM', then skip record. if not ElementExists(e, 'RNAM') then Exit;
//IntToHex converts the Value to a Hexadecimal string. IntToHex(Value, Digits) where Digits is the desired character length. s := IntToHex(FormID(e), 8); ID := RNAMList.IndexOf(s); if ID = -1 then begin recs[RNAMList.Count] := e; RNAMList.Add(s); AddMessage('Copying ' + FullPath(e));
end else recs[iD] := e; end;
function Finalize: integer; var i: integer; r, t: IInterface; begin if RNAMList.Count 0 then begin // Creates a new file where the above defined records will be stored. iAFile := AddNewFile; if not Assigned(iAFile) then begin AddMessage('Failed to create patch.'); Result := 1; Exit; end; for i := 0 to RNAMList.Count - 1 do begin r := recs; // Adds the current plugin as a master file. AddRequiredElementMasters(GetFile®, iAFile, False);
// copy CELL record to patch, parameters: record, file, AsNew, DeepCopy t := wbCopyElementToFile(r, iAFile, False, True); SetElementEditValues(t, 'RNAM', '');
AddMessage('Copied ' + FullPath®); end; AddMessage(Format('Patch file created with %d RNAM records.', [RNAMList.Count])); end else AddMessage('Script found no elements containing RNAM.'); RNAMList.Free; end;
end.
If anyone has any idea as to why the script runs so slowly on big files, please reply with any information. I'm at the end of the rope, and can't figure this one out.
I should also mention that my script runs very well and rapidly in the Procedure function, but extremely slowly on the Finalize function.
Question
MilletGtR
Hi fellow modders, I'm MilletGtR, the creator of iActivate on the Nexus.
I've just recently gotten into the world of pascal scripting, so please forgive me if my quesions have obvious answers :) I'll get right into my issue.
In iActivate, I have altered some of the game setting strings to hide the Activate text, such as "Open", "Talk" and "Search". The problem there is that some items in the world of Skyrim have an "Activate Text Override" defined, meaning it overwrites the game setting (Open, Search, Talk and so on). Initially I had the ambition to edit all of these objects by hand, to be included in the mods .esp, but that took a stop when I realized that it would require patch after patch to be compatible with some of the more popular mods out there.
Instead I decided to learn Pascal and create a script in TES5Edit that people can run and make their own patch for their own load order. I've now created a fully functional script which finds all relevant records which contains the element 'RNAM' (which is the code for Activate Text Override), copies them to a new file, and at the same time removes the string attatched to 'RNAM'.
Now I've come to my issue: The script works very well on small .esp's, but the bigger the plugin file, the longer it takes per record copied. It seems to be exponential.
Down below is my complete script. Due to my research I suspect that the culprit is the wbCopyElementToFile function, which to me seems to scan the entire record every single time the procedure is run.
If anyone has any idea as to why the script runs so slowly on big files, please reply with any information. I'm at the end of the rope, and can't figure this one out.
I should also mention that my script runs very well and rapidly in the Procedure function, but extremely slowly on the Finalize function.
Millet
Edited by MilletGtR19 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now