Guest User

Untitled

a guest
Sep 7th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. {
  2. Output meshes used in selected records
  3. }
  4. unit UserScript;
  5.  
  6. var
  7. s, t: string;
  8.  
  9. function Initialize: integer;
  10. var
  11. i: integer;
  12.  
  13. begin
  14. Result := 0;
  15. // ask for string to replace
  16. InputQuery('Enter', 'Path to replace', t);
  17. // ask for string to replace with
  18. InputQuery('Enter', 'New path', s);
  19. AddMessage('Replacing "' + t + '" with "' + s + '" in selected records...');
  20.  
  21. //Jax: I removed all of the if statements here so that it could handle empty strings
  22. end;
  23.  
  24. function Process(e: IInterface): integer;
  25. var
  26. N: IwbContainer;
  27. O, Z: integer;
  28. EditorID, FullName, oldPath, newPath: string; //Jax: Changed type from IInterface to string, added a new variable for the desired new string
  29. begin
  30. //Result := 0; Jax: At the moment, Result appears to be unnecessary in the process section, I could be wrong, but I never use it
  31. //AddMessage('Processing: ' + Name(e));
  32.  
  33. EditorID := GetElementEditValues(e, 'EDID - Editor ID');
  34. FullName := GetElementEditValues(e, 'FULL - Name');
  35.  
  36. O := 50;
  37. Z := 0;
  38. N := ElementByPath(e, 'Leveled List Entries');
  39. while Z < ElementCount(N) do begin
  40. while O > 0 do begin
  41. oldPath := GetElementEditValues((ElementByIndex(N, Z)), 'LVLO - Base Data\Level'); //Jax: e is already the proper element, use GetElementEditValues to retrieve data from a record
  42. AddMessage('Old path for ' + FullName + ' is ' + oldPath);
  43. newPath := StringReplace(oldPath, IntToStr(O), IntToStr(1), 0);
  44. AddMessage('New path for ' + FullName + ' is ' + newPath);
  45. //if Assigned(EditorID) then Jax: This line is unnecessary, to be honest I'm not even sure what Assigned does...
  46. if oldPath <> newPath then begin //will be used to make sure a change is even necessary
  47. SetElementEditValues((ElementByIndex(N, Z)), 'LVLO - Base Data\Level', newPath); //StringReplace does nothing by itself, it RETURNS a string without modifying the input string, use SetElementEditValues to edit data in a record
  48. AddMessage(' Changing Path of ' + Name((ElementByIndex(N, Z))) + '...');
  49. AddMessage(' From "' + EditorID + '" to "' + newPath + '"');
  50. end;
  51. O := O - 1;
  52. end;
  53. O := 50;
  54. Z := Z + 1;
  55. end;
  56. end;
  57. end.
  58.  
Advertisement
Add Comment
Please, Sign In to add comment