can_equip() and other item attributes

fronobulax

Developer
Staff member
See wiki here.

"equip" is something I do with equipment and in the context of KoL I expected can_equip() to be true if a character could wear an item or include it in an outfit. It turns out that can_equip() returns true for food and drink as well. Some investigating suggests that can_equip is named what it is because of its correlation to KoLmafia internals where "equip" is more generally defined as "eat, wear, drink or use to obtain something that effects the character".

What I want is to iterate through a list of items and know which ones the character can wear. What test or tests will tell me that in a script?

(I stick all sorts of stuff in my Display Case and pull it when I am going to use it. This is a quirk of Nevercore and trying to have the most unique items in the DC, a number that used to be computed once every 24 hours. But sometimes new or changed items mean I should reassess my outfits and pulling items and running the mazimizer is much easier than reading the wiki).

Related, is there a way scriptable to identify an item that can be used one or more times a day but is not consumed by such use? Those are also candidates for a DC pull strategy.

Thanks.
 

lostcalpolydude

Developer
Staff member
One easy way to identify equipment is to_slot( item ) != $slot[none].

There isn't a good way to know if an item is reusable for some daily benefit. You can start with item.reusable, but a lot of cases where that's true don't actually indicate that the item is worth using every day.
 

Veracity

Developer
Staff member
It turns out that can_equip() returns true for food and drink as well.
can_equip() calls EquipmentManager.canEquip() which looks only at equipment. It looks at all the possible ways you cannot wear a piece of equipment - path, class, stat requirements, what have you - and if none of them hold, it returns true.

I am quite sure that KoLmafia itself never calls EquipmentManager.canEquip on an item that is not actually equipment and therefore it never occurred to us that that we'd want to check.

Some investigating suggests that can_equip is named what it is because of its correlation to KoLmafia internals where "equip" is more generally defined as "eat, wear, drink or use to obtain something that effects the character".
I'm curious about what made you conclude that. I believe that can_equip is named what it is because it is the ASH interface to EquipmentManager.canEquip(). Again, it never occurred to us that an ASH coder would call can_equip() on something that wasn't actually equipment. RuntimeLibrary has it in the section labelled "Equipment functions".

What I want is to iterate through a list of items and know which ones the character can wear. What test or tests will tell me that in a script?
It would be trivial to modify can_equip() to check the item type and only call EquipmentManager.canEquip() for actual equipment, returning false, otherwise, but you could code up something in ASH to look at item_type() of the item. Or, as lost just suggested, check that the item actually has a slot that it goes on. :)

Related, is there a way scriptable to identify an item that can be used one or more times a day but is not consumed by such use?
How about

> ash $item[ Oscus's neverending soda ].reusable

Returned: true
 
Top