dagobaking Posted December 19, 2017 Share Posted December 19, 2017 (edited) I know that I can set up a FormList as a property in a script and use it that way. But, I would like to make one like this: FormList list = new FormList[0] list.AddForm(myForm)But, I get a compile error for that. I tried variations in syntax that I could think of and couldn't get it to work. Any ideas? Edited December 19, 2017 by dagobaking Link to comment Share on other sites More sharing options...
SKKmods Posted December 19, 2017 Share Posted December 19, 2017 From the syntax its tough to figure out what outcome you are trying to achieve ... if you are looking for an array of forms, try something like this: FormList[] ArrayofForms = new Formlist[0] ArrayofForms.Add(pSKK_WEAPList) ArrayofForms.Add(pSKK_OMODList) ArrayofForms.Add(pSKK_AMMOList) Int iCount = ArrayofForms.Length If you are wanting to simply add forms to another form: FormList MasterForm MasterForm.Add(pSKK_WEAPList) MasterForm.Add(pSKK_OMODList) MasterForm.Add(pSKK_AMMOList) Int iCount = MasterForm.GetSize() Link to comment Share on other sites More sharing options...
ThoraldGM Posted December 19, 2017 Share Posted December 19, 2017 The syntax would be: FormList[] list = new FormList[0] but if that works at all it would be a formlist of nested formlists, aka a multi array. I do that alot from CK, but not in script from scratch. If you just want a formlist declared by script, it would be: FormList list Guess it depends on what architecture you need. Edit: Ninja'd. I didn't see any answers when I replied. Link to comment Share on other sites More sharing options...
shavkacagarikia Posted December 19, 2017 Share Posted December 19, 2017 (edited) Just like guys suggested before me, but in case you have formlist form made and just dont want to make property and want to use that form in script. This is how you do it: FormList MyFormlistForm = Game.GetFormFromFile(0x0000F99, "MyCoolMod.esp") as FormList If MyFormListForm MyFormListForm.AddForm(MyCoolForm) Endif But properties are more efficient and fasterEdit: I read your question again and clearly you dont want what I have answered, but I will leave it just in case someone wants something like this. Edited December 19, 2017 by shavkacagarikia Link to comment Share on other sites More sharing options...
dagobaking Posted December 19, 2017 Author Share Posted December 19, 2017 From the syntax its tough to figure out what outcome you are trying to achieve ... if you are looking for an array of forms, try something like this: FormList[] ArrayofForms = new Formlist[0] ArrayofForms.Add(pSKK_WEAPList) ArrayofForms.Add(pSKK_OMODList) ArrayofForms.Add(pSKK_AMMOList) Int iCount = ArrayofForms.Length If you are wanting to simply add forms to another form: FormList MasterForm MasterForm.Add(pSKK_WEAPList) MasterForm.Add(pSKK_OMODList) MasterForm.Add(pSKK_AMMOList) Int iCount = MasterForm.GetSize() Thank you. My example was misleading. I am not trying to create an array of FormLists. I'm trying to simply populate a FormList that wasn't created as a property. So: FormList myList Function addToList(Form myForm) myList.Add(myForm) Debug.Notification(myList.GetSize()) EndFunctionThat results in a "0" notification when the addToList function is ran. But, if I set "myList" up as a property, it works. I was guessing that maybe I needed to instantiate the FormList like an array first. But, maybe what I'm trying to do is not possible at all in Papyrus. Maybe the engine needs to allocate space for it via a property...? The syntax would be: FormList[] list = new FormList[0] but if that works at all it would be a formlist of nested formlists, aka a multi array. I do that a lot from CK, but not in script from scratch. If you just want a formlist declared by script, it would be: FormList list Guess it depends on what architecture you need. Edit: Ninja'd. I didn't see any answers when I replied. Thank you. I initially tried it that way "FormList list". But, adding forms to that list didn't change the size of the list. When I change it to a property and set it up in CK, it then works... Just like guys suggested before me, but in case you have formlist form made and just dont want to make property and want to use that form in script. This is how you do it: FormList MyFormlistForm = Game.GetFormFromFile(0x0000F99, "MyCoolMod.esp") as FormList If MyFormListForm MyFormListForm.AddForm(MyCoolForm) Endif But properties are more efficient and faster Edit: I read your question again and clearly you dont want what I have answered, but I will leave it just in case someone wants something like this. Thank you. I think that would work. But, I'm trying to avoid having a CK FormList at all. I'm wanting to decouple the data side of this mod from CK as much as possible. Link to comment Share on other sites More sharing options...
ThoraldGM Posted December 19, 2017 Share Posted December 19, 2017 I'm wanting to decouple the data side of this mod from CK as much as possible. Any reason in particular? I work with FormLists frequently so want to make sure I'm not missing something useful. Also, if not already aware, you should know AddForm adds/prefixes at index 0 every time instead of appending. I flipped a few tables over this until I realized what was happening. See lines 107, 155, 225: https://pastebin.com/mSH8pJ6L i = 6 ; IMPORTANT: AddForm adds every new element at index ZERO! So add forms BACKWARDS to match globals list! While i >= 0 pDCS_Flst_Outfit_XautomatronX.AddForm(AutomatronOutfits[i] as Form) i -= 1 EndWhile If pDCS_Global_DevTracking.GetValue() == 1 Debug.Notification("DCS: Automatron handled.") EndIf Link to comment Share on other sites More sharing options...
dagobaking Posted December 20, 2017 Author Share Posted December 20, 2017 I'm wanting to decouple the data side of this mod from CK as much as possible. Any reason in particular? I work with FormLists frequently so want to make sure I'm not missing something useful. Also, if not already aware, you should know AddForm adds/prefixes at index 0 every time instead of appending. I flipped a few tables over this until I realized what was happening. See lines 107, 155, 225: https://pastebin.com/mSH8pJ6L i = 6 ; IMPORTANT: AddForm adds every new element at index ZERO! So add forms BACKWARDS to match globals list! While i >= 0 pDCS_Flst_Outfit_XautomatronX.AddForm(AutomatronOutfits[i] as Form) i -= 1 EndWhile If pDCS_Global_DevTracking.GetValue() == 1 Debug.Notification("DCS: Automatron handled.") EndIf My mod uses lists/data from xml files so that it can be expanded with modules without having to change the main mods files. That may be possible in some way with Papyrus/CK only. But, I found it very unwieldy. In the case of this list, to be honest, I'm just being a perfectionist. It is actually decoupled enough because I can still populate the list with data from the xml. Just, as a pattern, I'm avoiding entanglements with CK references as much as possible. Thank you for the note about the add order. The formlists I'm using so far don't need a particular order. But, I could see myself easily getting hung up by that later. Link to comment Share on other sites More sharing options...
Recommended Posts