Jump to content

Batch-Generating forms


pra

Recommended Posts

I just tried making my own settler renaming mod. It's mostly done, except for one minor detail: the actual names. I'm absolutely not going to manually create 100 or so MESGs. I've also seen that F4Edit is scriptable, though it's absolutely undocumented. From the examples there I could tell that it is at least capable of copying records of an ESP and writing and probably reading files.
I think it should be possible to script it in such a way that it takes a file with several names, and then just keeps copying the same MESG record over and over with a new string.

 

Has anyone here tried something like this? Or, is there an actual documentation of f4edit somewhere?

 

 

Link to comment
Share on other sites

Function documentation: http://www.creationkit.com/index.php?title=TES5Edit_Scripting_Functions

 

How I'd tackle the script:

 

Create text file of all the names

Load text file into a TStringsList variable

Use a for loop to run through the TStringsList, pulling a name from it after each iteration

Inside for loop, duplicate selected record by calling wbCopyElementToFile()

Inside for loop, change duplicated record's data

 

 

This is very simple. Would only take, like, 10-15 lines of actual code.

Link to comment
Share on other sites

Function documentation: http://www.creationkit.com/index.php?title=TES5Edit_Scripting_Functions

 

How I'd tackle the script:

 

Create text file of all the names

Load text file into a TStringsList variable

Use a for loop to run through the TStringsList, pulling a name from it after each iteration

Inside for loop, duplicate selected record by calling wbCopyElementToFile()

Inside for loop, change duplicated record's data

 

 

This is very simple. Would only take, like, 10-15 lines of actual code.

Oh. I was searching for f4edit, had no idea that I was supposed to look for TES5Edit. Thank you!

Link to comment
Share on other sites

I did it. The script isn't too clean and the file selection part is shamelessly stolen from another, but in case someone wants to do something similar, here it is:

 

 

unit BatchCreate;

var
  ToFile: IInterface;

function Process(e: IInterface): integer;
var
  i: integer;
  frm: TForm;
  clb: TCheckListBox;
  nameList: TStringList;
  newElem: IInterface;
  suffix: String;
begin
  if Signature(e) = 'TES4' then
    Exit;
    
    nameList := TStringList.Create;
    nameList.loadFromFile('d:\names\f4names-m.txt');
    
    
    suffix := 'm';
  if not Assigned(ToFile) then begin
    frm := frmFileSelect;
    try
      frm.Caption := 'Select a plugin';
      clb := TCheckListBox(frm.FindComponent('CheckListBox1'));
      clb.Items.Add('<new file>');
      for i := Pred(FileCount) downto 0 do
        if GetFileName(e) <> GetFileName(FileByIndex(i)) then
          clb.Items.InsertObject(1, GetFileName(FileByIndex(i)), FileByIndex(i))
        else
          Break;
      if frm.ShowModal <> mrOk then begin
        Result := 1;
        Exit;
      end;
      for i := 0 to Pred(clb.Items.Count) do
        if clb.Checked[i] then begin
          if i = 0 then ToFile := AddNewFile else
            ToFile := ObjectToElement(clb.Items.Objects[i]);
          Break;
        end;
    finally
      frm.Free;
    end;
    if not Assigned(ToFile) then begin
      Result := 1;
      Exit;
    end;
  end;

  AddMessage(GetElementEditValues(e, 'FULL'));

    for i := 0 to nameList.count-1 do begin
        AddMessage(nameList[i]);
        newElem := wbCopyElementToFile(e, ToFile, True, True);
        SetElementEditValues(newElem, 'FULL', nameList[i]);
        SetElementEditValues(newElem, 'EDID', 'baseName_'+suffix+IntToStr(i));
    end
  nameList.free();
end;

end.

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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