kts.GetNumHeld

Name

kts.GetNumHeld – count how many items of a particular type a creature is carrying

Synopsis

result = kts.GetNumHeld(creature, item_type)

Description

Given a Creature and an ItemType, returns the number of copies of the ItemType that the Creature is currently holding.

Return Value

A number (non-negative integer) is returned.

Errors

If the inputs are invalid, then an error will be generated.

Examples

The following could be used to detect whether the current actor is carrying any gems. (It is assumed that this code is being called from within an action function of some sort, for example on_walk_over in a Tile, and also, that the ItemType i_gem is defined somewhere.)

if kts.GetNumHeld(cxt.actor, i_gem) > 0 then
    -- Do something...
end

See Also

kts.ItemType