Jump to content

Automation Tools for TES5Edit - Suggestions Thread


matortheeternal

Recommended Posts

  • Replies 446
  • Created
  • Last Reply

Top Posters In This Topic

 

  Reveal hidden contents

 

I worked with it a little.

unit userscript;

var
 s1, slPath: string;
 i: integer;
 f, copyfile, ovrec: IInterface;
function Initialize: integer;
begin
  // initialize your stuff here
  // use InputBox to accept user input for filename, then use a loop to find that file and store it in a variable.  I do this in several of my scripts.
  // use a looping InputBox until the input is empty to add paths the user wants to copy things from to a stringlist: slPaths
   s1 := InputBox('File','Enter the name of the file containing the record you want to copy an element from, including the file extension','Skyrim.esm');
      for i := 0 to FileCount - 1 do begin
      f:= FileByIndex(i);
      if SameText(s1, GetFileName(f)) then begin
        copyfile := f;
        Break;
      end;
end;
slPath := InputBox('Path', 'Enter path you want to copy', '');
//here i have not array of pathes but only one. That's what i need
end;
function Process(e: IInterface): integer; 
begin
  for i := 0 to OverrideCount(e) - 1 do begin
    if Name(GetFile(OverrideByIndex(e, i))) = Name(copyfile) then then begin
      ovrec := OverrideByIndex(e, i);
      Break;
    end;
  end;
    wbCopyElementToRecord(e, ElementByPath(ovrec, slPath), False, True);
	//changeg first boolean to False because it is referred as "aAsNew"... And what i need is to replace old record (weight or price), not to add something new.
	//doesn't work both with True of False anyway
  end;
end.

Doesn't change anything. I cannot find any mistakes.

Could you please fix it?

Edited by DanielUA
Link to comment
Share on other sites

  On 10/15/2013 at 4:06 PM, DanielUA said:

Thanks! I'll change code above. But still doesn't work.

  • You have two thens at line "if Name(..."
  • I don't think it's a good idea to use Name for filenames. Use GetFileName()
  • You don't need to store the copyfile as an IInterface object, you only need the file name, which should be a global string variable.
  • Fix your indentation, please, it's difficult to read because it's all wrong.
  • Put an empty line between functions, this also helps with readability.
  • Use an if Assigned(ovrec) line to skip the copying if ovrec isn't found.
  • Learn to troubleshoot your own code. This is actually pretty simple, just use AddMessage() to add messages when an if statement returns true or false, and when a variable should be assigned/found. This will let you troubleshoot exactly where in your code things aren't working. E.g.
      for i := 0 to OverrideCount(e) - 1 do begin
        AddMessage('Comparing filenames: '+GetFileName(GetFile(OverrideByIndex(e, i)))+' vs. '+GetFileName(copyfile));
        if GetFileName(GetFile(OverrideByIndex(e, i))) = GetFileName(copyfile) then begin
          ovrec := OverrideByIndex(e, i);
          AddMessage('ovrec assigned: '+GetElementEditValues(ovrec, 'EDID'));
          Break;
        end;
      end;
Edited by matortheeternal
Link to comment
Share on other sites

Mator, would you be able to give me access to the quick-change script? Need to sort through a bunch of containers so as to reduce the amount of items in a couple of containers; there's around 150 values to be changed total, and it's an absolute pain to go through them in the CK.

Link to comment
Share on other sites

  On 10/15/2013 at 8:40 PM, FiftyTifty said:

Mator, would you be able to give me access to the quick-change script? Need to sort through a bunch of containers so as to reduce the amount of items in a couple of containers; there's around 150 values to be changed total, and it's an absolute pain to go through them in the CK.

https://github.com/matortheeternal/AutomationTools

 

 

NPC Generator 1.1 was just uploaded. Works with all races and genders now. Let me know how the generated NPCs look to you.

Link to comment
Share on other sites

Is there anything that will automatically count all the items in any list so I don't have to?
Annoying sometimes to have count each item myself sometimes to ensure i enter the correct number of items in a list.

Edited by JobVanDam
Link to comment
Share on other sites

  On 10/15/2013 at 11:34 PM, JobVanDam said:

Is there anything that will automatically count all the items in any list so I don't have to?

Annoying sometimes to have count each item myself sometimes to ensure i enter the correct number of items in a list.

 

When you say "List" what do you mean?

  • StringLists in pascal code?
  • Arrays in pascal code?
  • Records in a group (with a signature) in TES5Edit?
  • Elements in a container in TES5Edit?
  • Records after filtering?

 

- M

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...