Difference between revisions of "GetMiscComponents - MiscObject"

1,440 bytes added ,  20:29, 2 December 2018
code example
imported>Jimhsu
(Added return value and example.)
imported>Qazaaq
(code example)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Incomplete Article}}
'''F4SE Member of:''' [[MiscObject Script]]
'''F4SE Member of:''' [[MiscObject Script]]
{{Template:Papyrus:RequiredF4SE|version=0.4.2}}
{{Template:Papyrus:RequiredF4SE|version=0.4.2}}


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


== Syntax ==
== Syntax ==
Line 14: Line 13:


== Return Value ==
== Return Value ==
An array of MiscComponent structs.
An array of [[MiscComponent Struct - MiscObject|MiscComponent]] structures.


== Examples ==
== Examples ==
<source lang="papyrus">
<source lang="papyrus">
MiscObject:MiscComponent[] Components = new MiscObject:MiscComponent[10]
; Count how many different types of components are used
Components = akTheMod.GetMiscComponents()
MiscObject DeskFanOffice01
 
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 lang="papyrus">
Scriptname Example extends ScriptObject
import MiscObject
 
MiscObject Property DeskFanOffice01 Auto Const Mandatory
 
Event OnInit()
    {For each miscellaneous component}
    MiscComponent[] components = DeskFanOffice01.GetMiscComponents()
    If (components)
        int index = 0
        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 ==
*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 ==
*[[MiscObject Script]]
*[[MiscItem]]
*[[Component]]
*[[MiscComponent Struct - MiscObject]]
*[[SetMiscComponents - MiscObject]]




[[Category: Scripting]]
[[Category:Scripting]]
[[Category: Papyrus]]
[[Category:Papyrus]]
[[Category: F4SE]]
[[Category:F4SE]]
Anonymous user