Difference between revisions of "GetMiscComponents - MiscObject"

code example
imported>Qazaaq
(Added notes.)
imported>Qazaaq
(code example)
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
{{Template:Papyrus:RequiredF4SE|version=0.4.2}}
{{Template:Papyrus:RequiredF4SE|version=0.4.2}}


Gets an array of [[MiscComponent Struct - MiscObject|MiscComponent]] for this [[MiscItem]].
Gets the ''[[Template:Editor:Property:Component Data|Component Data]]'' for this [[MiscItem]] as an array of [[MiscComponent Struct - MiscObject|MiscComponent]] structures.


== Syntax ==
== Syntax ==
Line 17: Line 17:
== Examples ==
== Examples ==
<source lang="papyrus">
<source lang="papyrus">
; Count miscellaneous components
; Count how many different types of components are used
int count = Item.GetMiscComponents().Length
MiscObject DeskFanOffice01
Debug.Trace(Item + " has " + count + " components.")
 
int count = DeskFanOffice01.GetMiscComponents().Length
If (count == 1)
    Debug.Trace(DeskFanOffice01 + " has one type of component.")
ElseIf (count > 1)
    Debug.Trace(DeskFanOffice01 + " has "+count+" types of component.")
Else
    Debug.Trace(DeskFanOffice01 + " has no components.")
EndIf
</source>
</source>




<source lang="papyrus">
<source lang="papyrus">
{For each miscellaneous component}
Scriptname Example extends ScriptObject
MiscObject:MiscComponent[] components = Item.GetMiscComponents()
import MiscObject
If (components)
 
    int index = 0
MiscObject Property DeskFanOffice01 Auto Const Mandatory
    While (index < components.Length)
 
        Debug.Trace(Item + " uses " + components[index].Count + " of the " + components[index].Object + " component.")
Event OnInit()
        index += 1
    {For each miscellaneous component}
    EndWhile
    MiscComponent[] components = DeskFanOffice01.GetMiscComponents()
Else
    If (components)
    Debug.Trace(Item + " has no components.")
        int index = 0
EndIf
        While (index < components.Length)
            Debug.Trace("("+index+" of "+components.Length+") There is "+components[index].Count+" of the '"+components[index].Object+"' component")
            index += 1
        EndWhile
    Else
        Debug.Trace(DeskFanOffice01+" has no components.")
    EndIf
EndEvent
</source>
</source>


== Notes ==
== Notes ==
*Do not use these functions on ConstructibleObject they will not work. Papyrus defines Constructible as extends MiscObject when this is not remotely true internally and F4SE does not support this kind of conversion in code so these are separate functions.
*Do not use these functions on [[Constructible Object]] as they will not work. Papyrus defines [[ConstructibleObject Script]] as extends [[MiscObject Script]] when this is not remotely true internally and F4SE does not support this kind of conversion in code so these are separate functions.


== See Also ==
== See Also ==
Line 44: Line 59:
*[[Component]]
*[[Component]]
*[[MiscComponent Struct - MiscObject]]
*[[MiscComponent Struct - MiscObject]]
*[[SetMiscComponents - MiscObject]]




Anonymous user