Jump to content

Help with tweaking the FO4Edit "find ESPs that can be flagged as ESLs" script?


teresatiger

Recommended Posts

Hello, does anyone know how to adjust this script to ONLY return results for the first option (Can be turned into ESL by adding ESL flag in TES4 header) but NOT show any results for the other two options (the compacting, etc. ones)?

 

I just want to see the ESPs that can be easily flagged as ESLs and nothing more. But I'm not sure how to adjust the script to do that.

 

At the moment, I ended up just removing the other two return conditions so that they simply list the esp names and no additional information, which helps to scroll through and find the ones I can flag. But removing them from the results entirely would certainly be preferable, if it's possible. So Any help woud be greatly appreciated!

{
  Find plugins which can be converted to ESL
}
unit FindPotentialESL;

const
  iESLMaxRecords = $800; // max possible new records in ESL
  iESLMaxFormID = $fff; // max allowed FormID number in ESL


procedure CheckForESL(f: IInterface);
var
  i: Integer;
  e: IInterface;
  RecCount, RecMaxFormID, fid: Cardinal;
  HasCELL: Boolean;
begin
  // iterate over all records in plugin
  for i := 0 to Pred(RecordCount(f)) do begin
    e := RecordByIndex(f, i);
    
    // override doesn't affect ESL
    if not IsMaster(e) then
      Continue;
    
    if Signature(e) = 'CELL' then
      HasCell := True;
    
    // increase the number of new records found
    Inc(RecCount);
    
    // no need to check for more if we are already above the limit
    if RecCount > iESLMaxRecords then
      Break;
    
    // get raw FormID number
    fid := FormID(e) and $FFFFFF;
    
    // determine the max one
    if fid > RecMaxFormID then
      RecMaxFormID := fid;
  end;

  // too many new records, can't be ESL
  if RecCount > iESLMaxRecords then
    Exit;
 
  AddMessage(Name(f));
 
  if RecMaxFormID <= iESLMaxFormID then
    AddMessage(#9'Can be turned into ESL by adding ESL flag in TES4 header')
  else
    AddMessage(#9'Can be turned into ESL by compacting FormIDs first, then adding ESL flag in TES4 header');
    
  // check if plugin has new cell(s)
  if HasCELL then
    AddMessage(#9'Warning: Plugin has new CELL(s) which won''t work when turned into ESL and overridden by other mods due to the game bug');
end;
 
function Initialize: integer;
var
  i: integer;
  f: IInterface;
begin
  // iterate over loaded plugins
  for i := 0 to Pred(FileCount) do begin
    f := FileByIndex(i);
    // skip the game master
    if GetLoadOrder(f) = 0 then
      Continue;
    // check non-light plugins only
    if (GetElementNativeValues(ElementByIndex(f, 0), 'Record Header\Record Flags\ESL') = 0) and not SameText(ExtractFileExt(GetFileName(f)), '.esl') then
      CheckForESL(f);
  end;
end;


end.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...