Difference between revisions of "GetObjectComponentCount - MiscObject"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Qazaaq
m (fixed wiki link)
imported>Qazaaq
(changed code example)
 
Line 1: Line 1:
[[Category:Scripting]]
[[Category:Papyrus]]
'''Member of:''' [[MiscObject Script]]
'''Member of:''' [[MiscObject Script]]


Returns the number of the given [[Component]] this form has.
Gets the quantity of the given [[Component]] from the [[MiscItem]] ''Component Data''.


== Syntax ==
== Syntax ==
<source lang="papyrus">
<source lang="papyrus">
int Function GetObjectComponentCount( Component akComponent ) native
int Function GetObjectComponentCount(Component akComponent) native
</source>
</source>


== Parameters ==
== Parameters ==
*akComponent - The component you are interested in.
*akComponent - The [[Component]] that should be counted.


== Return Value ==
== Return Value ==
The number of the given component this form has.
The quantity of the given [[Component]].


== Examples ==
== Examples ==
<source lang="papyrus">
<source lang="papyrus">
if item.GetObjectComponentCount( Screws ) > 1
; Count the miscellaneous components
  Debug.Trace("This item has too many screws. The game is now unbalanced.")
MiscObject DeskFanOffice01
endIf
Component c_Screws
 
int count = DeskFanOffice01.GetObjectComponentCount(c_Screws)
Debug.Trace("The '"+DeskFanOffice01+"' item has "+count+" of the "+c_Screws+" component.")
</source>
 
 
<source lang="papyrus">
Scriptname Example extends ScriptObject
 
MiscObject Property DeskFanOffice01 Auto Const Mandatory
Component Property c_Screws Auto Const Mandatory
 
Event OnInit()
    {Count the miscellaneous components}
    int count = DeskFanOffice01.GetObjectComponentCount(c_Screws)
    If (count > 0)
        Debug.Trace("The '"+DeskFanOffice01+"' item has "+count+" of the "+c_Screws+" component.")
    Else
        Debug.Trace("The '"+DeskFanOffice01+"' item does not use the "+c_Screws+" component.")
    EndIf
EndEvent
</source>
</source>


== See Also ==
== See Also ==
*[[MiscItem]]
*[[MiscItem]]
*[[Component]]
[[Category:Scripting]]
[[Category:Papyrus]]

Latest revision as of 19:00, 2 December 2018

Member of: MiscObject Script

Gets the quantity of the given Component from the MiscItem Component Data.

Syntax[edit | edit source]

int Function GetObjectComponentCount(Component akComponent) native

Parameters[edit | edit source]

  • akComponent - The Component that should be counted.

Return Value[edit | edit source]

The quantity of the given Component.

Examples[edit | edit source]

; Count the miscellaneous components
MiscObject DeskFanOffice01
Component c_Screws

int count = DeskFanOffice01.GetObjectComponentCount(c_Screws)
Debug.Trace("The '"+DeskFanOffice01+"' item has "+count+" of the "+c_Screws+" component.")


Scriptname Example extends ScriptObject

MiscObject Property DeskFanOffice01 Auto Const Mandatory
Component Property c_Screws Auto Const Mandatory

Event OnInit()
    {Count the miscellaneous components}
    int count = DeskFanOffice01.GetObjectComponentCount(c_Screws)
    If (count > 0)
        Debug.Trace("The '"+DeskFanOffice01+"' item has "+count+" of the "+c_Screws+" component.")
    Else
        Debug.Trace("The '"+DeskFanOffice01+"' item does not use the "+c_Screws+" component.")
    EndIf
EndEvent

See Also[edit | edit source]