Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.37 KB | None | 0 0
  1. {
  2.   Filtering by papyrus script name.
  3. }
  4. unit ApplyFilterForPapyrusScript;
  5.  
  6. var
  7.   sScriptName: string;
  8.   bSkipSection: Boolean;
  9.  
  10. function HasScript(e: IInterface; aScript: string): Boolean;
  11. var
  12.   i: integer;
  13. begin
  14.   if Name(e) = 'scriptName' then begin
  15.     Result := SameText(GetEditValue(e), aScript);
  16.     bSkipSection := True;
  17.   end else
  18.     for i := 0 to Pred(ElementCount(e)) do begin
  19.       Result := HasScript(ElementByIndex(e, i), aScript);
  20.       if bSkipSection then begin
  21.         bSkipSection := False;
  22.         Exit;
  23.       end;
  24.       if Result then Exit;
  25.     end;
  26. end;
  27.  
  28. function Filter(e: IInterface): Boolean;
  29. begin
  30.   if ElementExists(e, 'VMAD') then
  31.     Result := HasScript(ElementBySignature(e, 'VMAD'), sScriptName);
  32. end;
  33.  
  34. function Initialize: Integer;
  35. begin
  36.   if wbGameMode <> gmTES5 then begin
  37.     AddMessage('Filtering by papyrus script works only for Skyrim.');
  38.     Result := 1;
  39.     Exit;
  40.   end;
  41.  
  42.   if not InputQuery('Filter By', 'Papyrus script name (case insensitive)', sScriptName) then begin
  43.     Result := 1;
  44.     Exit;
  45.   end;
  46.  
  47.   if sScriptName = '' then begin
  48.     Result := 1;
  49.     Exit;
  50.   end;
  51.  
  52.   FilterConflictAll := False;
  53.   FilterConflictThis := False;
  54.   FilterByInjectStatus := False;
  55.   FilterInjectStatus := False;
  56.   FilterByNotReachableStatus := False;
  57.   FilterNotReachableStatus := False;
  58.   FilterByReferencesInjectedStatus := False;
  59.   FilterReferencesInjectedStatus := False;
  60.   FilterByEditorID := False;
  61.   FilterEditorID := '';
  62.   FilterByName := False;
  63.   FilterName := '';
  64.   FilterByBaseEditorID := False;
  65.   FilterBaseEditorID := '';
  66.   FilterByBaseName := False;
  67.   FilterBaseName := '';
  68.   FilterScaledActors := False;
  69.   FilterByPersistent := False;
  70.   FilterPersistent := False;
  71.   FilterUnnecessaryPersistent := False;
  72.   FilterMasterIsTemporary := False;
  73.   FilterIsMaster := False;
  74.   FilterPersistentPosChanged := False;
  75.   FilterDeleted := False;
  76.   FilterByVWD := False;
  77.   FilterVWD := False;
  78.   FilterByHasVWDMesh := False;
  79.   FilterHasVWDMesh := False;
  80.   FilterBySignature := False;
  81.   FilterSignatures := '';
  82.   FilterByBaseSignature := False;
  83.   FilterBaseSignatures := '';
  84.   FlattenBlocks := False;
  85.   FlattenCellChilds := False;
  86.   AssignPersWrldChild := False;
  87.   InheritConflictByParent := False;
  88.   FilterScripted := True; // use custom Filter() function
  89.  
  90.   ApplyFilter;
  91.  
  92.   Result := 1;
  93. end;
  94.  
  95. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement