Jump to content

A formlist of containers?


Recommended Posts

I created ten containers in the CK (all duplicates of a single base object)

I then created a formlist - dz_auto_outfits_hidden_container_formlist in the CK and added the ten containers to it.

My script has an array of these containers such:

ObjectReference[] Property hidden_container   Auto

a property:

FormList Property dz_auto_outfits_hidden_container_formlist Auto

the property is filled in the CK with the formlist created above, and the script fills the array with:

Function dz_fill_containers()
Int i = 2
While i < 12
  hidden_container[i] = dz_auto_outfits_hidden_container_formlist.GetAt(i) As ObjectReference
  i += 1
EndWhile
EndFunction

Should this result in an array (hidden_container[]) of containers that can be treated as such?

 

diziet

Link to comment
Share on other sites

Probably. But why not create and fill the array in the CK and skip the formlist?

ObjectReference[] Property hidden_container Auto

This would get you an array property that you can then fill with the pre-placed container references in whatever order you want. And because it is a property, you won't be limited to 128 entries (should you ever need to have that many).

Link to comment
Share on other sites

Probably. But why not create and fill the array in the CK and skip the formlist?

That makes sense, I created an interior cell in the CK to put my ten duplicates of the base container into. Is the right way to go about this? I could create ten duplicate base objects in the CK instead? Will the cell need to be loaded to access the containers?

 

diziet

Link to comment
Share on other sites

This cell doesn't need to be loaded to access the containers. I've used hidden containers in an empty dummy cell in a bunch in my mods. I prefer your method, filling the array oninit because you can drag and drop into formlists but you can't drag and drop into arrays. If your formlist contains base objects of the containers, you'll want to place object references of them in your script.

ObjectReference Property CellRef Auto ;an ObjectReference in your cell
Formlist Property dz_auto_outfits_hidden_container_formlist Auto
ObjectReference[] Property hidden_container Auto

Function dz_fill_containers()
    Int i = 0
    While i < 10
      hidden_container = New ObjectReference[10] ;create new array with 10 possible entries
      hidden_container[i] = CellRef.PlaceAtMe(dz_auto_outfits_hidden_container_formlist.GetAt(i), 1, true) ;place new permanent container at CellRef and save to array.    
      i += 1
    EndWhile
EndFunction

Alternatively, you can place your containers in the cell directly in the ck render window, then add the object references of those containers to your formlist. Drag and drop them from the Cell View window, and the script would be like you had it, except keep the hidden_container = New ObjectReference[10] line to initialize the array.

Link to comment
Share on other sites

dizietemblesssma please read cdcooley's answer with focus to formlist versus arrays. Here https://forums.nexusmods.com/index.php?/topic/6031618-vmad-or-form-list-which-is-quicker/

I am sorry dylbill, but the array initialization should be out of the loop.

  ObjectReference   Property CellRef              auto          ; a marker inside your cell
  ObjectReference   Property ContainerBaseObject  auto          ; the conainers baseobject to place near the marker from above
  ObjectReference[] Property hiddenContainerArray auto Hidden   ; filled at runtime, ("all duplicates of a single base object")

;;Formlist Property dz_auto_outfits_hidden_container_formlist Auto        ; obsolete

;----------------------------
FUNCTION dz_fill_containers()
;----------------------------
; https://www.creationkit.com/index.php?title=PlaceAtMe_-_ObjectReference

    IF (hiddenContainerArray.Length == 10)
        ; array is valid
    ELSE
        hiddenContainerArray = new ObjectReference[10]            ; initialize array for 10 possible entries
    ENDIF

int i = 10
    WHILE (i)        ; (i != 0)
        i = i - 1
        hiddenContainerArray[i] = CellRef.PlaceAtMe(ContainerBaseObject as Form, 1, TRUE)    ; place new container (persistent and enabled) at CellRef and store them to the array.   
    ENDWHILE
ENDFUNCTION
Edited by ReDragon2013
Link to comment
Share on other sites

Ok, this is what I have in the CK:

 

 

If I understand correctly, then I'm only missing the initialisation of the array:

hidden_container = New ObjectReference[10] ;create new array with 10 possible entries

which as reminded by ReDragon should be outside the loop, in my case I shall put it up the top of my script where the OnVersionUpdate Event lives (this is an MCM script)

With the containers in a cell in the CK I don't need the:

ObjectReference Property CellRef Auto ;an ObjectReference in your cell

?

 

diziet

Link to comment
Share on other sites

  • Recently Browsing   0 members

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