Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Output meshes used in selected records
- }
- unit UserScript;
- var
- s, t: string;
- function Initialize: integer;
- var
- i: integer;
- begin
- Result := 0;
- // ask for string to replace
- InputQuery('Enter', 'Path to replace', t);
- // ask for string to replace with
- InputQuery('Enter', 'New path', s);
- AddMessage('Replacing "' + t + '" with "' + s + '" in selected records...');
- //Jax: I removed all of the if statements here so that it could handle empty strings
- end;
- function Process(e: IInterface): integer;
- var
- N: IwbContainer;
- O, Z: integer;
- EditorID, FullName, oldPath, newPath: string; //Jax: Changed type from IInterface to string, added a new variable for the desired new string
- begin
- //Result := 0; Jax: At the moment, Result appears to be unnecessary in the process section, I could be wrong, but I never use it
- //AddMessage('Processing: ' + Name(e));
- EditorID := GetElementEditValues(e, 'EDID - Editor ID');
- FullName := GetElementEditValues(e, 'FULL - Name');
- O := 50;
- Z := 0;
- N := ElementByPath(e, 'Leveled List Entries');
- while Z < ElementCount(N) do begin
- while O > 0 do begin
- oldPath := GetElementEditValues((ElementByIndex(N, Z)), 'LVLO - Base Data\Level'); //Jax: e is already the proper element, use GetElementEditValues to retrieve data from a record
- AddMessage('Old path for ' + FullName + ' is ' + oldPath);
- newPath := StringReplace(oldPath, IntToStr(O), IntToStr(1), 0);
- AddMessage('New path for ' + FullName + ' is ' + newPath);
- //if Assigned(EditorID) then Jax: This line is unnecessary, to be honest I'm not even sure what Assigned does...
- if oldPath <> newPath then begin //will be used to make sure a change is even necessary
- 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
- AddMessage(' Changing Path of ' + Name((ElementByIndex(N, Z))) + '...');
- AddMessage(' From "' + EditorID + '" to "' + newPath + '"');
- end;
- O := O - 1;
- end;
- O := 50;
- Z := Z + 1;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment