Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UserScript;
- uses mteFunctions;
- var
- files, masters: TStringList;
- userFile: IInterface;
- procedure FixRNAM(g: IInterface);
- var
- i: integer;
- r: IInterface;
- s1, s2: string;
- begin
- for i := 0 to Pred(ElementCount(g)) do begin
- r := ElementByIndex(g, i);
- s1 := Copy(EditorID(r), 1, 35);
- s2 := Copy(EditorID(r), 1, 9);
- if not ElementExists(r, 'RNAM') then // Skips all records which doens't contain RNAM.
- continue;
- if s1 = 'DLC2ApocryphaConstellationActivator' then // Skips all records with the editorID s1. Needed because of unwanted edits.
- continue;
- if s2 = 'CWMapFlag' then // Skips all records with the editorID s2. Needed because of unwanted edits.
- continue;
- AddMessage(' Fixing '+Name(r));
- try
- r := wbCopyElementToFile(r, userFile, false, true); //If record gets through all the above criteria, copies the record to the userfile.
- SetElementEditValues(r, 'RNAM', ''); //Preforms the actual change by replacing the RNAMs string with nothing: '')
- except
- on x : Exception do AddMessage(' Failed to fix record. '+x.Message);
- end;
- end;
- end;
- function Initialize: Integer;
- var
- i: integer;
- begin
- i := MessageDlg('Before running this script, please be sure to read the installation section for iActivate on the Nexus.'+Chr(13)+''+Chr(13)+'Are you sure you wish to continue?', mtConfirmation, [mbYes, mbCancel], 0);
- if i = mrYes then begin
- end else begin
- Result := 1;
- Exit;
- end;
- files := TStringList.Create;
- masters := TStringList.Create;
- ScriptProcessElements := [etFile]; // Process function will only get the files the user selected
- end;
- function Process(e: IInterface): Integer;
- begin
- if StrEndsWith(GetFileName(e), '.dat') then exit; // Skips hardcoded objects
- files.AddObject(GetFileName(e), TObject(e));
- AddMastersToList(e, masters);
- end;
- function Finalize: Integer;
- var
- i: integer;
- f, g: IInterface;
- begin
- if files.Count = 0 then begin
- AddMessage('No files selected. Terminating script.');
- files.Free;
- masters.Free;
- exit;
- end;
- userFile := AddNewFile;
- if not Assigned(userFile) then begin
- AddMessage('Failed to create patch.');
- files.Free;
- masters.Free;
- exit;
- end;
- AddMastersToFile(userFile, masters, true);
- for i := Pred(files.Count) downto 0 do begin
- f := ObjectToElement(files.Objects[i]);
- AddMessage('Processing file: '+files[i]);
- // Process ACTI record group (Action)
- g := GroupBySignature(f, 'ACTI');
- if Assigned(g) then begin
- AddMessage(' Processing Group: ACTI');
- FixRNAM(g);
- end;
- // Process FLOR record group (Flora)
- g := GroupBySignature(f, 'FLOR');
- if Assigned(g) then begin
- AddMessage(' Processing Group: FLOR');
- FixRNAM(g);
- end;
- end;
- // Clean masters
- CleanMasters(userFile);
- // Free memory
- files.Free;
- masters.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement