Background for Fallout 4
Member of the InstanceData script
voidfunctionSetKeywords(InstanceData:OwnerakOwner, Keyword[]kwds)NativeGlobal


Caveats


Parameters

InstanceData:OwnerakOwner

CK Wiki Description

Placeholder Description.

Keyword[]kwds

CK Wiki Description

Placeholder Description.


Examples

; set up the weapon instance
int slotIndex = Game.GetPlayer().GetEquippedItemType(0) + 32
instanceData:Owner myInstance = Game.GetPlayer().GetInstanceOwner(slotIndex)

; we want to add the keyword MyKeyword to our instance using an easy-to-use function
instanceData.SetKeywords(myInstance, editKeywords(instancedata.GetKeywords(myInstance), MyKeyword, "add"))

; we want to remove the keyword MyKeyword from our instance using an easy-to-use function
instanceData.SetKeywords(myInstance, editKeywords(instancedata.GetKeywords(myInstance), MyKeyword, "remove"))

; this will add / remove a keyword from a chosen array
Keyword[] Function editKeywords(Keyword[] mainArray, keyword keywordToUse, string sAction)
    ; generate an empty array
    Keyword[] tempArray = new Keyword[0]
    ; populate the empty array with the array on the instance
    tempArray = mainArray
    ; options on how to modify the array
    if sAction == "add"
        ; add the keyword into the array
        tempArray.Add(keywordToUse)
        ; return our array with the keyword added
        return tempArray
    elseIf sAction == "remove"
        ; find the position of the keyword 
        int removeFrom = tempArray.Find(keywordToUse)
        ; remove the keyword from that position
        tempArray.Remove(removeFrom)
        ; return our array with the keyword removed
        return tempArray
    endIf
endFunction

Auto-Generated Example

InstanceData:Owner myInstanceData_Owner__akOwner
Keyword[] myKeywordArray__kwds

InstanceData.SetKeywords(myInstanceData_Owner__akOwner, myKeywordArray__kwds)

Related Pages


Additional References

View this function’s page on the Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.