Difference between revisions of "HasKeyword - Form"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
(→‎Examples: fixed syntax for the example "CurrentLocationHasKeyword". With additional check to return false if the location is none.)
imported>Lisselli
Line 45: Line 45:
EndFunction
EndFunction


debug.trace("Is this location a house?: " +CurrentLocationHasKeyword(LocTypeHouse))
debug.trace("Is this location a house?: " +CurrentLocationHasKeyword(Game.GetPlayer(), LocTypeHouse))
</source>
</source>


== See Also ==
== See Also ==
*[[Form Script]]
*[[Form Script]]

Revision as of 03:28, 9 August 2017

Member of: Form Script

Checks to see if the specified keyword is attached to this form.

Syntax

bool Function HasKeyword(Keyword akKeyword) native

Parameters

  • akKeyword: The Keyword to query for.

Return Value

Whether this form has the specified keyword or not. If the form doesn't support keywords, it will always return false.

Examples

ScriptName ExampleScript Extends ObjectReference

Keyword Property DoomKeywordProperty Auto

Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akFormReference, ObjectReference akSourceContainer)
	If akBaseItem.HasKeyword(DoomKeywordProperty) ; Does the added object have a doom keyword?
		Debug.Trace("The added sword is a doom sword")
	EndIf
EndEvent

;Check if the current location has a keyword.

Keyword property LocTypeHouse auto

Bool Function CurrentLocationHasKeyword(ObjectReference akRef, Keyword akKeyword)
        Location kCurrentLoc = akRef.GetCurrentLocation()
        if (kCurrentLoc == none)
                return false
        endif

        if kCurrentLoc.HasKeyword(akKeyword)
                return true
        else
                return false
        endif
EndFunction

debug.trace("Is this location a house?: " +CurrentLocationHasKeyword(Game.GetPlayer(), LocTypeHouse))

See Also