Jump to content

[Papyrus] Check Form for ArmorLight/ArmorHeavy/... keywords gives Warnings


Recommended Posts

Posted (edited)

I wanted to make my scripts more clean and reduce errors in the Papyrus Log file (the errors are not damaging my mods function, but I thought it is still worth a try and maybe it speeds up the script, I dont know...)

 

Anyway,

 

I need to check items that are WORN by the PC and items in PC inventory if they are Light Armor, Heavy Armor or Clothing (among others).

 

But I noticed this:

 

I have an Heavy Armor Item as Form and check it for ArmorLight Keyword and the papyrus log returns:

 

 

[02/25/2025 - 12:31:10PM] WARNING: Assigning None to a non-object variable named "::temp260"
stack:

 

Since they code is a bit much to paste here, this is the order I m doing things:

Int iFormIndex = PlayerRef.GetNumItems()
RobbedItem = PlayerRef.GetNthForm(iFormIndex)
RobbedItem.HasKeyword(XYZ)

 

and If I check the RobbedItem that is HEAVY ARMOR for "ArmorLight" or "Clothing" Keyword it returns the above Warning stacks. 
since I use alot of those checks the logs get very full very fast with those.... 

it returns true ofc when I check for the "ArmorHeavy" Keyword. 

Moving stuff between containers is not an option, I need to check stuff the player is wearing during combat too.

 

The SKSE function (IsCuirass() etc.) were not helpful at all, they produced even more errors and warnings. 

Edited by Nymra
Posted

You should consider using Actor.wornHasKeyword instead.

 

As you described your code, it is likely not going to work.  "PlayerRef.GetNumItems()" returns the number of item forms, and thus valid indices for "getNthForm" go from 0 to n-1.  As I read your sample code, RobbedItem is always None, and "RobbedItem.HasKeyword(XYZ)" will fail with a message to the log.

 

Getting "WARNING: Assigning None to a non-object variable named "::temp260"" means that you have some invalid intermediate result in an expression.  If you get that message in an expression such as "myref.somefunction() && othercondition", it's generally because "myref" is None.  If that's not what y,ou expected, find out why myref is None instead of what it should be.  If it's normal for myref to be None, then rewrite the expression to handle that explicitely: "myref && myref.somefunction() && othercondition".

 

That same message is used for all manners of complex expressions; by complex I mean that it is made of more than one subexpression on one variable's value (myref.getParentCell().isAttached() has two subexpressions, is complex and can give that message).

 

Posted (edited)
29 minutes ago, pfB6cs said:

You should consider using Actor.wornHasKeyword instead.

 

This is not an option since this seems not to be a function that I can use to also determine the slot of the item (which I also need).

 

29 minutes ago, pfB6cs said:

 

As you described your code, it is likely not going to work.  "PlayerRef.GetNumItems()" returns the number of item forms, and thus valid indices for "getNthForm" go from 0 to n-1.  As I read your sample code, RobbedItem is always None, and "RobbedItem.HasKeyword(XYZ)" will fail with a message to the log.

 

I use the Num Items in "while" loop to check all the times.

Functions/Script Snippets are in the spoiler
 

Spoiler

    Int iFormIndex = PlayerRef.GetNumItems()    
            Int iFormCount
            Form RobbedItem
            String ItemName
                        
                ;RobbedGold = Utility.RandomInt(GoldMin,Gold)
                ;OLD: PlayerRef.RemoveItem(Gold001, RobbedGold, True, akRobber)            
                PlayerRef.RemoveItem(Gold001, Gold, True, akRobber)        
                
                While iFormIndex > 0
                    iFormIndex -= 1
                    RobbedItem = PlayerRef.GetNthForm(iFormIndex)
                    
                    if RobbedItem
                    ItemName = RobbedItem.GetName()
                    
                        if !ItemName
                        ItemName = "NoName"
                        endif 
                    
                        ;if !ItemName
                        ;ItemName = RobbedItem.GetBaseObject().GetName()
                        ;endif 
                    else
                    ItemName = "NoItem > NoName"
                    endif                    
                    
                    if RobbedItem && !RobbedItem.HasKeyword(SexlabNoStrip)
                    DebugTrace("ItemToCheck: "+ItemName)
                    
                        if CheckItem(RobbedItem)
                        iFormCount = PlayerRef.GetItemCount(RobbedItem)
                        PlayerRef.RemoveItem(RobbedItem, iFormCount, True, akRobber)
                        else
                        DebugTrace("ItemBlockedFromRobbery: "+ItemName)
                        endif
                        
                    DebugTrace("ItemRobbed: "+ItemName)    
                    else
                    DebugTrace("Not Robbed (SexlabNoStrip): "+ItemName)
                    endif
                    
                EndWhile
                
                PlayerRef.QueueNiNodeUpdate()



 

Bool Function CheckItem(Form akItem)        ;#CheckItem 

NymTrace("CheckItem(Start)")

Bool IsArmor = false

 

if IsItem("Armor Type Light", akItem) || IsItem("Armor Type Heavy", akItem) || IsItem("Armor Type Clothing", akItem) || IsItem("Jewelery", akItem) 
NymTrace("IsArmorA")
;if (akItem as armor).IsLightArmor()|| (akItem as armor).IsHeavyArmor() || (akItem as armor).IsClothing() || (akItem as armor).IsJewelry()
;DebugTrace("Robbery IS armor/clothing (SKSE): " +akItem.GetName())
IsArmor = true
else
....



 

Bool Function IsItem(String sKeyword, Form fWornItem )        ;#IsItem()

 

    if sKeyword == "Armor Type Clothing"
        
            if fWornItem.HasKeyword(KeywordsArmorClothing[0])
            NymTrace("ItemIs Clothing")
            return true 
            endif 

 

    elseif sKeyword == "Armor Type Light"
    
    
            if fWornItem.HasKeyword(KeywordsArmorClothing[1])

            NymTrace("ItemIs Light Armor")
            return true 
            endif 
    
    elseif     sKeyword == "Armor Type Heavy"
    
        if fWornItem.HasKeyword(KeywordsArmorClothing[2])
        NymTrace("ItemIs Heavy Armor")
        return true 
        endif 


 

 

29 minutes ago, pfB6cs said:

 

Getting "WARNING: Assigning None to a non-object variable named "::temp260"" means that you have some invalid intermediate result in an expression.  If you get that message in an expression such as "myref.somefunction() && othercondition", it's generally because "myref" is None.  If that's not what y,ou expected, find out why myref is None instead of what it should be.  If it's normal for myref to be None, then rewrite the expression to handle that explicitely: "myref && myref.somefunction() && othercondition".

 

That same message is used for all manners of complex expressions; by complex I mean that it is made of more than one subexpression on one variable's value (myref.getParentCell().isAttached() has two subexpressions, is complex and can give that message).

 

 

the thing that bugs me is, that RobbedItem / MyRef is not NONE (I check that before).

 

its more like this:

 

MyFormHeavyArmor (I know it is Heavy Armor, the script does not)

 

if MyFormHeavyArmor.HasKeyword(ArmorLight) ---> returns false AND produces the WARNING: Assigning None to a non-object variable named "::temp260"

 

if MyFormHeavyArmor.HasKeyword(ArmorHeavy)  ---> returns true without the warning.

 

This is what I just dont understand.... 

 

 



 

 

 

Edited by Nymra
Posted (edited)
1 hour ago, Nymra said:

MyFormHeavyArmor.HasKeyword(ArmorLight)

("ArmorLight")

 

If you define the string as property ArmorLight , then you can use (ArmorLight)

 

 

 

Edited by Tlam99
Posted (edited)
16 minutes ago, Tlam99 said:

("ArmorLight")

 

If you define the string as property ArmorLight , then you can use (ArmorLight)

 

 

I dont understand?
I have all the Keywords as a Property in my script, its just named differently and I use the strings to keep overview.

 

The strings are only used to tell the function which keyword to check.

And again: the poperty is correct. the problem seems to be with the keywords?
 

If I check the HEavy Armor Form for heavyarmor keyword no warning is issued and the function works as expected.

 

It is as if I cannot check a Heavy Armor piece for the Armor Light keyword, which bugs me, since what other method of identifying armor types are left then? 

 

 

Edited by Nymra
Posted
3 hours ago, Nymra said:

[02/25/2025 - 12:31:10PM] WARNING: Assigning None to a non-object variable named "::temp260"
stack

Is this not typically because a function has exited without actually returning a value. 

(You're missing a return somewhere)

 

Disclaimer: I didn't read everything fully

Posted
8 minutes ago, Monoman1 said:

Is this not typically because a function has exited without actually returning a value. 

(You're missing a return somewhere)

 

Disclaimer: I didn't read everything fully

 

oh, interesting point that I did not explore yet. I ll double check. 

Posted
31 minutes ago, Monoman1 said:

Is this not typically because a function has exited without actually returning a value. 

(You're missing a return somewhere)

 

Disclaimer: I didn't read everything fully

 

yes, it was this. warning is gone now with correct return options.

I wrongly assumed that the function will return false automatically in this case. 

 

thanks to everyone for your time. 

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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