Jump to content

Getting item's type


Dooge

Recommended Posts

Posted

So this always says false even if the item is clothing or armor

bool function IsArmor(Form akItem)
  if  (akItem as armor).IsLightArmor() || (akItem as Armor).IsHeavyArmor() || (akItem as Armor).IsClothing() \
      || (akItem as Armor).IsBoots() || (akItem as Armor).IsCuirass() || (akItem as Armor).IsGauntlets() || (akItem as Armor).IsHelmet() \
      || (akItem as Armor).IsShield() || (akItem as Armor).IsJewelry() || (akItem as Armor).IsClothingHead() \
      || (akItem as Armor).IsClothingBody() || (akItem as Armor).IsClothingFeet() || (akItem as Armor).IsClothingHands() \
      || (akItem as Armor).IsClothingRing() || (akItem as Armor).IsClothingRich() || (akItem as Armor).IsClothingPoor() 
    return true
  else
    return false
  endif
endfunction

How do I test what type of an item I have?

Posted

If you don't mind having a SKSE dependency, and all you want is TRUE when the form is an armor/clothing, and FALSE otherwise, then this will do:

If (akItem.GetType() == 26)
    return true
Else
    return false
EndIf

Why 26? Reference.

 

 

If that's not an option, then you'll want to check if akItem in your code is actually being successfully cast into an Armor. If not, then you'll always just get FALSE and a bunch of Papyrus log errors.

 

 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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