Jump to content

Inventory-safe HasKeyword not working on equipped item


spacefiddle

Recommended Posts

TL;DR Fixed - using self. instead of the variable I cast as an ObjectReference seems to have gotten it working again.

 

I keep seeing in my logs

error: Cannot check for a None keyword
as the result of this part of a script:

Event OnEquipped(Actor akActor)
     armorPiece = self as ObjectReference
     RegisterForHitEvent(akActor)
     Debug.Trace( "SCARCITY: " + armorPiece + " equipped, registered for hits on " + akActor )
     if armorPiece.HasKeyword(ap_PowerArmor_LLegMod)
         ...more stuff...
This is attached to every PA piece; to use one script for all of them, it needs to identify which bodypart it's for when it's equipped.

I'd rather not have to make six versions of the silly thing, one for each piece, applied to all PA =/

 

Before trying to use the attach point, I was using the basic keywords like dn_PowerArmor_Torso for each piece. Same error.

 

Thanks!

 

Update: I tried switching to

if playerRef.WornHasKeyword(dn_PowerArmor_LeftLeg)
and now I'm getting "error: Cannot check worn items against a None keyword," which I don't get at all. So it's not the functions - either one, probably - but somehow it seems to be unable to read the keywords, suddenly.

 

I think I need to figure out why it's not reading the keywords, and then the first method will work... I tried it to test, but using Worn will only identify the player has the piece on, not necessarily that *this* object running this instance of the script is that piece.

 

Very weird.

 

Update: Fixt! I think. The problem may have been

armorPiece = self as ObjectReference
  if armorPiece.HasKeyword(dn_PowerArmor_LeftLeg)
Well, turns out that this item doesn't like being cast as an ObjectReference when it's checking for keywords; using instead

if self.HasKeyword(dn_PowerArmor_LeftLeg)
seems to be working. It wants the Form, not the inaccessible reference of an inventory item.
Link to comment
Share on other sites

TL;DR Fixed - using self. instead of the variable I cast as an ObjectReference seems to have gotten it working again.

 

I keep seeing in my logs

error: Cannot check for a None keyword

 

The error is telling you that you haven't filled the keyword Property.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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