Advertisement
Sharlikran

Replace paths

Dec 30th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.15 KB | None | 0 0
  1. {
  2.   Replace paths
  3. }
  4. unit UserScript;
  5. var
  6.   oldPath: string;
  7.   newPath: string;
  8.  
  9. function Initialize: integer;
  10. begin
  11.   oldPath := 'DX\MiniArmorsCollection';
  12.   newPath := 'TESVPlus\Clothes\GweldaUNP';
  13. end;
  14.  
  15. function Process(e: IInterface): integer;
  16. var
  17.   s: string;
  18.   i: integer;
  19.   found: integer;
  20.   editedPath: string;
  21. begin
  22.   Result := 0;
  23.  
  24.   // only string fields can contain filenames
  25.  
  26.   i := DefType(e);
  27.   if (i = dtString) or (i = dtLenString) then begin
  28.     s := GetEditValue(e);
  29.     if SameText(Copy(s, Length(s) - 3, 4), '.nif') or SameText(Copy(s, Length(s) - 3, 4), '.dds') or SameText(Copy(s, Length(s) - 3, 4), '.tri') then
  30.       begin
  31.         found := Pos(oldPath, s);
  32.         if found > 0 then
  33.           begin
  34.             editedPath := newPath + Copy(s, Length(oldPath) + 1, Length(s) - Length(oldPath));
  35.             AddMessage(s + ' --> ' + editedPath);
  36.             SetEditValue(e, editedPath);
  37.           end;
  38.       end;
  39.   end;
  40.  
  41.   // recursively process all child elements
  42.   for i := 0 to ElementCount(e) - 1 do
  43.     Process(ElementByIndex(e, i));
  44.  
  45. end;
  46.  
  47. function Finalize: integer;
  48. begin
  49.   AddMessage('Done');
  50. end;
  51. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement