Difference between revisions of "HasKeyword - Form"
Jump to navigation
Jump to search
imported>DiemCarpe |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 18: | Line 18: | ||
== Examples == | == Examples == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
ScriptName ExampleScript Extends ObjectReference | |||
Keyword Property DoomKeywordProperty | Keyword Property DoomKeywordProperty Auto | ||
; Does | Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akFormReference, ObjectReference akSourceContainer) | ||
if ( | 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)) | |||
</source> | </source> | ||
== Notes == | |||
* If run on a Spell, this function checks all attached magic effects, and returns true if at least one magic effect has a specified keyword. | |||
* If run on an Ingredient or a Potion, this function '''does not''' checks attached magic effects, only the record itself. | |||
== See Also == | == See Also == | ||
*[[Form Script]] | *[[Form Script]] |
Latest revision as of 07:42, 12 July 2023
Member of: Form Script
Checks to see if the specified keyword is attached to this form.
Syntax[edit | edit source]
bool Function HasKeyword(Keyword akKeyword) native
Parameters[edit | edit source]
- akKeyword: The Keyword to query for.
Return Value[edit | edit source]
Whether this form has the specified keyword or not. If the form doesn't support keywords, it will always return false.
Examples[edit | edit source]
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))
Notes[edit | edit source]
- If run on a Spell, this function checks all attached magic effects, and returns true if at least one magic effect has a specified keyword.
- If run on an Ingredient or a Potion, this function does not checks attached magic effects, only the record itself.