Jump to content


Photo

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


Best Answer zilav , 02 April 2018 - 12:32 AM

formids := ElementByName(formList, 'FormIDs');
SetEditValue( ElementAssign(formids, HighInteger, nil, False), Name(weapon) );
Go to the full post


  • Please log in to reply
3 replies to this topic

#1 IWantMyMod

IWantMyMod

    Prisoner

  • Members
  • 15 posts

Posted 01 April 2018 - 10:31 PM

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?


  • 0

#2 zilav

zilav

    Thane

  • Mod Authors
  • PipPipPipPipPipPip
  • 361 posts

Posted 02 April 2018 - 12:32 AM   Best Answer

formids := ElementByName(formList, 'FormIDs');
SetEditValue( ElementAssign(formids, HighInteger, nil, False), Name(weapon) );

Edited by zilav, 02 April 2018 - 12:32 AM.

  • 0

#3 IWantMyMod

IWantMyMod

    Prisoner

  • Members
  • 15 posts

Posted 07 April 2018 - 01:54 PM

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?


  • 0

#4 zilav

zilav

    Thane

  • Mod Authors
  • PipPipPipPipPipPip
  • 361 posts

Posted 08 April 2018 - 12:58 AM

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) );

  • 0


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users