Jump to content

How to use SKSE function 'addforms'


Recommended Posts

I must not understand the syntax of the above function, here is my code:

Formlist Function dz_get_kit(Actor aRef)

Formlist ItemList                ;temporary formlaist

Form[] Items                 ;temporary array

Items = PO3_SKSEFunctions.AddAllEquippedItemsToArray(aRef)      ;fill array with equipped items

ShowMessage("items = "+Items,False)

ItemList.AddForms(Items)              ;add temp array items to formlist

ShowMessage("ItemList is "+ItemList,False)

Return ItemList                 ;return items as a formlist

EndFunction

The temporary array 'Items' is filled and the debug 'showmessage' confirms that, but the following line:

ShowMessage("ItemList is "+ItemList,False)

always returns "itemlist is NONE".

 

The SKSE version of Formlist.psc says:

; Adds an Array of Forms to this list
Function AddForms(Form[] forms) native

 

So it would seem I'm misinterpreting how to use it.

 

 

diziet

Link to comment
Share on other sites

Try an actual FormList record. Create an empty FormList record and assign it to a property. Then you can utilize a function like this instead:

FormList Property ItemList Auto
 
Function dz_get_kit(Actor aRef)
  Form[] Items                 ;temporary array
  Items = PO3_SKSEFunctions.AddAllEquippedItemsToArray(aRef)      ;fill array with equipped items
  ShowMessage("items = "+Items,False)
  ItemList.AddForms(Items)
  ShowMessage("ItemList is "+ItemList,False)
EndFunction

 

 

 

With any luck it will work. If it doesn't, then I'm just as clueless cause I've never used that function before.

Edited by IsharaMeradin
Link to comment
Share on other sites

Try an actual FormList record. Create an empty FormList record and assign it to a property. Then you can utilize a function like this instead:

 

With any luck it will work. If it doesn't, then I'm just as clueless cause I've never used that function before.

I added the line:

FormList Property ItemList Auto

to the top of my script and in the CK the value of the property was 'NONE', is that correct?

 

edited the function as you showed and no joy.

seems I need a new way to add the array items to a formlist,

 

 

diziet

Link to comment
Share on other sites

No, not correct. You need to actually create a formlist record, just leave the record itself empty. Assign said formlist record to the property.

Ok that seems to work, my only concern is that now I have to make sure that the formlist defined as a property is empty each time the funtuion it is in runs, so I now have:

Formlist Function dz_get_kit(Actor aRef)
Formlist empty_formlist               ;temporary formlist
Itemlist = empty_formlist
Form[] Items                 ;temporary array
Items = PO3_SKSEFunctions.AddAllEquippedItemsToArray(aRef)      ;fill array with equipped items
ShowMessage("items = "+Items,False)
ItemList.AddForms(Items)              ;add temp array items to formlist
ShowMessage("ItemList is "+ItemList,False)
Return ItemList                 ;return items as a formlist
EndFunction

will:

Formlist empty_formlist ;temporary formlist

Itemlist = empty_formlist

 

be sufficient?

 

 

diziet

Link to comment
Share on other sites

Just run Revert on the formlist. Revert removes all script added entries. Since the formlist is empty to begin with... see where I'm going with it?

 

Like so:

 

 

  ItemList.Revert()
  Form[] Items                 ;temporary array
  Items = PO3_SKSEFunctions.AddAllEquippedItemsToArray(aRef)      ;fill array with equipped items
  ShowMessage("items = "+Items,False)
  ItemList.AddForms(Items)
  ShowMessage("ItemList is "+ItemList,False)

 

FYI - Unless your are calling the function from another script, you do not need make it return a formlist as you can use the property throughout the script as needed instead.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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