Jump to content

Recommended Posts

Posted (edited)

I am trying to create a formlist of baseobjects from a formlist of refids.

Function dz_move_armour(ObjectReference akref,Formlist akList,Bool keep, ObjectReference destination)
	debug.trace("DDHH: function dz_move_armour called")
	;;;need to create formlist of items to move using formlist of baseobjects;;;
	
	FormList baselist = DbSKSEFunctions.CreateFormList()
	Int i = akList.getSize()
	While i > 0
		i -= 1
		baselist.AddForm((akList.GetAt(i) As ObjectReference).getbaseObject())
		debug.trace("DDHH: akList("+i+") is "+akList.getAt(i))
		debug.trace("DDHH: baselist("+i+") is "+baselist.getAt(i))
	EndWhile
	;RemoveListFromContainer(ObjectReference akRef, FormList akList, bool abNoEquipped = false, bool abNoFavorited = false, bool abNoQuestItem = false, ObjectReference akDestination = None)  global native
	PO3_SKSEFunctions.RemoveListFromContainer(akRef,baselist,keep,keep,keep,PlayerRef)

EndFunction

But in papyrus.0.log I see:

  Reveal hidden contents

The baselist is created using dylbill's function but some of the refids in 'aklist' don't have baseobjects,

the problem is that the formlist 'akList' is a CK created list and has 103 objectreferences in it.  so shouldn't every refid in akList have a baseobject?

 

diziet

Edited by dizietemblesssma
added extra debug statement and new log excerpt
Posted (edited)

You realise you are spinning the loop backwards but when you add to a new list it goes to first spot and adds moving forwards? So the indices presay do not match up with the debug code

that why the change kicks in at the halfway point 

[06/10/2025 - 04:11:33PM] DDHH: akList(52) is [dbm_dynamicdisplayscript < (1192138E)>]
[06/10/2025 - 04:11:33PM] DDHH: baselist(52) is None
[06/10/2025 - 04:11:33PM] DDHH: akList(51) is [dbm_dynamicdisplayscript < (11921349)>]
[06/10/2025 - 04:11:33PM] DDHH: baselist(51) is [Form < (1182724A)>]

here let fix me that debug code for you

Function dz_move_armour(ObjectReference akref,Formlist akList,Bool keep, ObjectReference destination)
   debug.trace("DDHH: function dz_move_armour called")
   ;;;need to create formlist of items to move using formlist of baseobjects;;;
   
   FormList baselist = DbSKSEFunctions.CreateFormList()
   Int i = akList.getSize()
   int j = 0 ; for debugging only
   While i > 0
      i -= 1
      baselist.AddForm((akList.GetAt(i) As ObjectReference).getbaseObject())
      debug.trace("DDHH: akList("+i+") is "+akList.getAt(i))
      debug.trace("DDHH: baselist("+j+") is "+baselist.getAt(j))
      j += 1 ; for debugging only
   EndWhile
   ;RemoveListFromContainer(ObjectReference akRef, FormList akList, bool abNoEquipped = false, bool abNoFavorited = false, bool abNoQuestItem = false, ObjectReference akDestination = None)  global native
   PO3_SKSEFunctions.RemoveListFromContainer(akRef,baselist,keep,keep,keep,PlayerRef)

EndFunction

basically lists have Iterators and Nodes, not Indices and Elements.  And you failed to take that into account

 

EDIT do me a solid and post the log output, something not quite right with your logic. and I would like to double check it))) before I go into it.

Edited by PeterMartyr
edit... and typo
Posted (edited)

Maybe I can be of some help, but I still have a lot to learn about the CK. I don’t really know what the root of the issue is, but it does seem rather odd that your baselist isn’t returning any forms. Clearly your akList has the references, so I wonder if this is a problem more specific to DbSKSEFunctions.CreateFormList()?


I would try this if you haven't already:

debug.trace("DDHH: akList("+i+") is "+(akList.getAt(i) as ObjectReference).GetBaseObject())

See what that actually returns, if it still gets none, then I am not sure if I am knowledgeable enough to help you there. If it is actually getting something, my only advice would be to abandon using that DbSKSE function.


If you are trying to accomplish what I think you are doing here, which is adding a list of base objects to a container using a FormList of references that are placed in the game world somewhere, then perhaps the PO3_SKSEFunctions.RemoveListFromContainer isn’t the best way to go about that.


I would do something like this:

Function dz_move_armour(Formlist akList, ObjectReference destination) ;dropped akref and keep since they are no longer necessary
	debug.trace("DDHH: function dz_move_armour called")
	;;;add the forms directly to the container by getting the base objects of a FormList consisting of references;;;
	
	Int i = akList.getSize()
	While i > 0
		i -= 1
		destination.AddItem((akList.GetAt(i) As ObjectReference).getbaseObject())
		debug.trace("DDHH: akList("+i+") added "+(akList.GetAt(i) As ObjectReference).getbaseObject())
	EndWhile

EndFunction


I don’t know if this will work or if this accomplished your goal, but I hope it helps.

Edited by GumboMods
Posted

@GumboMods AddItem will create a new instance of the passed in base item. References may move from their current location to target location.  However, I find it best to stick with RemoveItem for moving items from one location to another.

 

@dizietemblesssma Just reverse your while loop.  As @PeterMartyr said, lists are built from index 0.  Your source list won't have matching indexes to your destination list without starting at index 0. See as follows:

Int i = 0
While i < akList.getSize()
  baselist.AddForm((akList.GetAt(i) As ObjectReference).getbaseObject())
  debug.trace("DDHH: akList("+i+") is "+akList.getAt(i))
  debug.trace("DDHH: baselist("+i+") is "+baselist.getAt(i))
  i += 1
EndWhile

Now if you were working with arrays instead of form lists, you could go in reverse as arrays will fill in the designated index provided the array has enough entries assigned to it.

Posted

I see it now, thanks everyone.  If I had put the debug statements in their own while loop after filling the baselist then I would have seen 100 odd baseobjects (though not in the same order as the refids).  So I've been wrong in assuming that the baselist didn't actually have the contents it did have, because I didn't wait until after the list was full to examine it!

Reversing the while loop is clearly the way to go:)

 

diziet

  • Recently Browsing   0 members

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