Skip to content

Instantly share code, notes, and snippets.

@DavidJCobb
Created April 20, 2019 05:27
Show Gist options
  • Save DavidJCobb/1e215477a3d322d313584063680e6625 to your computer and use it in GitHub Desktop.
Save DavidJCobb/1e215477a3d322d313584063680e6625 to your computer and use it in GitHub Desktop.
Skyrim - xEdit - Count the number of persistent references in all worldspaces in a file
Unit CobbCountPersistents;
Var
giCount: Integer;
Function Initialize: Integer;
Var
eFile: IInterface;
eWorlds: IInterface;
eWorld: IInterface;
eTemporary: IInterface;
eCell: IInterface;
iIterator1: Integer;
iIterator2: Integer;
Begin
giCount := 0;
//
For iIterator1 := 0 To FileCount - 1 Do Begin
eFile := FileByIndex(iIterator1);
eWorlds := GroupBySignature(eFile, 'WRLD');
For iIterator2 := 0 To ElementCount(eWorlds) - 1 Do Begin
eWorld := ElementByIndex(eWorlds, iIterator2);
eTemporary := ChildGroup(eWorld);
eCell := ElementByName(eTemporary, '<Persistent Worldspace Cell>');
eTemporary := ChildGroup(eCell);
eTemporary := FindChildGroup(eTemporary, 8, eCell);
//
giCount := giCount + ElementCount(eTemporary);
If ElementCount(eTemporary) <> 0 Then
AddMessage(
Format(
'Found %d persistent references in worldspace %s.',
[
Integer(ElementCount(eTemporary)), // cast needed -- because of JvInterpreter, I think
Name(eWorld)
]
)
);
End;
End;
AddMessage(
'Found ' + IntToStr(giCount) + ' total persistent references.'
);
End;
End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment