Jump to content
  • 0

How do I add an item to a FormList with a script


IWantMyMod

Question

Lets say I have this:

pluginFile := FileByIndex('My Plugin');
weapon := RecordByEditorID(pluginFile, 'MyWeapon');
formList := RecordByEditorID(pluginFile, 'MyFormList');

So I have an IInterface for a weapon and an IInterface for a FormList.  How do I add the weapon to the formList?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thank you. I would have never figured that out on my own.  I wish I could find more well annotated examples of how to do various common tasks.

 

I discovered that RecordByEditorID() will not return an ARMO or FLST so I have to use MainRecordByEditorID(GroupBySignature(skyrim, 'ARMO'), 'ArmorDaedricShield') for example.

 

Also I discovered that if the FormList has no item then formids := ElementByName(formList, 'FormIDs') will return null and SetEditValue( ElementAssign(formids, HighInteger, nil, False), Name(weapon) ) fails.

 

I tried using formids := Add(formList, 'FormIDs', true). It worked but I end up with a null item in the list. Is there a way to add an empty FormIDs to the FormList?

Link to comment
Share on other sites

  • 0

No, you can't add empty arrays in xEdit, it always creates an empty entry in them automatically. You can use that empty element with proper checks

formids := ElementByName(formList, 'FormIDs');
if not Assigned(formids) then
  SetEditValue( ElementByIndex(Add(formList, 'FormIDs', True), 0), Name(weapon) )
else
  SetEditValue( ElementAssign(formids, HighInteger, nil, False), Name(weapon) );
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.