Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Gets all the child records in CELL and WRLD records.
- }
- unit UserScript;
- uses mteFunctions;
- const
- verbose = true;
- procedure GetRecords(var RecordsList: TList; var g: IInterface);
- var
- i: Integer;
- e: IInterface;
- begin
- // exit if the group/container isn't assigned
- if not Assigned(g) then exit;
- if ElementType(g) = etMainRecord then begin
- if verbose then AddMessage('Found etMainRecord '+Name(g));
- if (Signature(g) = 'CELL') or (Signature(g) = 'WRLD') then
- GetRecords(RecordsList, ChildGroup(g))
- else
- RecordsList.Add(g);
- end
- else begin
- if verbose then AddMessage('Processing '+IntToStr(ElementCount(g))+' child elements in '+Name(g));
- for i := 0 to Pred(ElementCount(g)) do begin
- e := ElementByIndex(g, i);
- GetRecords(RecordsList, e);
- end;
- end;
- end;
- function Initialize: Integer;
- var
- sig: string;
- f, g, e: IInterface;
- RecordsList: TList;
- sl: TStringList;
- i: Integer;
- begin
- RecordsList := TList.Create;
- f := FileSelect('Select the file you want to get records from.');
- // get the records from WRLD and CELL groups
- g := GroupBySignature(f, 'WRLD');
- GetRecords(RecordsList, g);
- g := GroupBySignature(f, 'CELL');
- GetRecords(RecordsList, g);
- // save record names to file
- sl := TStringList.Create;
- for i := 0 to Pred(RecordsList.Count) do begin
- e := ObjectToElement(RecordsList[i]);
- sl.Add(Name(e));
- end;
- sl.SaveToFile('Get REFR Records.txt');
- // clean up
- sl.Free;
- RecordsList.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment