Jump to content

How to properly read item keywords with Papyrus?


elguapo1991

Recommended Posts

I have a script attached to my player alias. The intent is to do something I equip a weapon made of silver, and to do something else if it is not. Here's the script sample:

Scriptname PlayerAliasScript_Main extends ReferenceAlias  

Keyword Property WeapMaterialSilver auto

Event OnObjectEquipped(Form akBaseItem, ObjectReference akReference)
	if akBaseItem as Weapon
		if akBaseItem.HasKeyword(WeapMaterialSilver)
			Debug.Notification("Is Silver")
		else
			Debug.Notification("Is Not Silver")
		endIf
	else
		; Do nothing for now
	endIf
endEvent

Scripts all compile with 0 errors.

 

When I run the game, no matter what weapon I equip, the "Is Not Silver" notification pops up even if I know the weapon I equipped has that keyword. What am I missing?

 

Thanks.

Link to comment
Share on other sites

Two things:

 

1. Don't use the line # option of the code box. It does an alternating color scheme that doesn't work well with the automatic colored text. :P

 

2. Did you fill the WeapMaterialSilver property? i.e. press the properties button and assign a value to it by either auto-fill or manual assignment. If not, then that is likely why. The script would be looking for a weapon that has a NONE keyword and so all weapons would fail that check.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...