HasKeyword help

Post » Mon Nov 19, 2012 9:35 am

The wiki is still young, and needs a lot of editing to make it a better one for those new to Papyrus. One of the extremely bland pages is HasKeyWord. I don't know a lot about Papyrus, to be honest it just isn't a very logical scripting language, but this keeps befuddling me. Here is an example of my script so far:



Event OnHit (ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

bool Function HasKeyword(Keyword akKeyword) native


If akSource.HasKeyword(WeapTypeBow)
endif

endEvent

When I try to compile my script, there are two errors it gives me:

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\DMKillShots.psc(15,5): no viable alternative at input 'Function'
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\DMKillShots.psc(17,1): no viable alternative at input 'If'

what does it mean by no viable alternative input?
User avatar
Emma
 
Posts: 3287
Joined: Mon Aug 28, 2006 12:51 am

Post » Mon Nov 19, 2012 8:09 am

Scriptname TestScript extends ObjectReferenceKeyword property WeapTypeBow autoEvent OnHit (ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)If akSource.HasKeyword(WeapTypeBow); do somethingendifendEvent


This compiles. Don't forget to fill your weaptypebow property :smile:

You don't need that function line in this script.
User avatar
stephanie eastwood
 
Posts: 3526
Joined: Thu Jun 08, 2006 1:25 pm

Post » Mon Nov 19, 2012 1:34 pm

Wow... I feel stupid >.< I forgot to make the property. Anyways, thanks for clarifying the whole HasKeyWord function. I'm going to improve that page to hopefully help some people out.
User avatar
Kelly James
 
Posts: 3266
Joined: Wed Oct 04, 2006 7:33 pm


Return to V - Skyrim