Jump to content

test if an object is a container


Recommended Posts

Here is a listing of script objects: https://www.creationkit.com/index.php?title=Category:Script_Objects

 

Every pre-placed object is an ObjectReference. This includes containers. ObjectReference is a child of Form. Children can be cast upwards to their parents.

Container is a child of Form. Parents can be cast downwards to their child. But will fail if the object is not valid for that child. (See Cast Reference)

 

Given that bit of information, assume an object reference is stored in a variable called myRef.

If ((myRef as Form) as Container)
  ;is a container do something
Else
  ;is not a container do something else
EndIf

And as already mentioned SKSE's GetType can inform you if an object is a container.

If (myRef.GetBaseObject().GetType() == 28)
  ;is a container do something
Else
  ;is not a container do something else
EndIf
Link to comment
Share on other sites

  • Recently Browsing   0 members

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