Jump to content
  • 0

Processing all records that meet a condition


IWantMyMod

Question

Hello.

 

I'm trying to future out how to process all records that meet some condition.  It seem like I should be able to use a custom filter and the Process function but so far that doesn't seem to work. It applies the custom filter then stops.  Here is the example test code:

unit ApplyCustomScripted;

function Filter(e: IInterface): Boolean;
begin
  Result := GetElementNativeValues(e, 'Record Header\Record Flags\Shield') <> 0;
end;

function Initialize: Integer;
begin
  FilterConflictAll := False;
  FilterConflictThis := False;
  FilterByInjectStatus := False;
  FilterInjectStatus := False;
  FilterByNotReachableStatus := False;
  FilterNotReachableStatus := False;
  FilterByReferencesInjectedStatus := False;
  FilterReferencesInjectedStatus := False;
  FilterByEditorID := False;
  FilterEditorID := '';
  FilterByName := False;
  FilterName := '';
  FilterByBaseEditorID := False;
  FilterBaseEditorID := '';
  FilterByBaseName := False;
  FilterBaseName := '';
  FilterScaledActors := False;
  FilterByPersistent := False;
  FilterPersistent := False;
  FilterUnnecessaryPersistent := False;
  FilterMasterIsTemporary := False;
  FilterIsMaster := False;
  FilterPersistentPosChanged := False;
  FilterDeleted := False;
  FilterByVWD := False;
  FilterVWD := False;
  FilterByHasVWDMesh := False;
  FilterHasVWDMesh := False;
  FilterBySignature := True;
  FilterSignatures := 'ARMO';
  FilterByBaseSignature := False;
  FilterBaseSignatures := '';
  FlattenBlocks := False;
  FlattenCellChilds := False;
  AssignPersWrldChild := False;
  InheritConflictByParent := False; // color conflicts
  FilterScripted := True; // use custom Filter() function

  ApplyFilter;
end;

function Process(e: IInterface): integer;
begin
	AddMessage(GetElementEditValues(e, 'FULL'));
end;

end.

If I want to preform some action on all shields or all axes only what is the best way to do that.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

It turns out my example from above does work. Originally I had the "Result := 1;" at the end of the "Initialize" function like so many examples show. By removing it the test script does exactly what I expected it to do. It sets a filter for all shield records then list the name of all shields to the log.

 

A return value other then 0 from Initialize, Process, or Finalize indicates an error which causes the script to stop. So I'm not sure why that's at the end of the Initialize function in example filter scripts.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Guidelines, Privacy Policy, and Terms of Use.