kts.Drop – drop an item from the actor's inventory
kts.Drop(item_type)
result = kts.Can_Drop(item_type)
If the current actor (given by cxt.actor
) is a knight, who is currently carrying at least one item of type item_type
in their "backpack", then kts.Drop(item_type)
will drop one or more items of that type.
The number of items dropped is equal to either the max_stack
property of the given ItemType, or the number of items of that type already carried by the knight, whichever is lower.
If the knight is currently approaching a tile (such as a table or chest), then the item(s) will be dropped onto that tile if possible; otherwise, they will be dropped on the knight's current square. Alternatively, if the target tile is already "full" (i.e. it already contains a different item type, or more than the max_stack
value of the item type being dropped), then the item(s) may be placed on another nearby tile instead.
kts.Can_Drop(item_type)
will return true if it is currently possible for the knight to drop at least one item of the given type, or false otherwise.
kts.Drop
returns nothing, and kts.Can_Drop
returns a boolean as described above.
This function can only be used to drop "backpack" items (like gems or daggers), not items "held in hands" (like hammers or crossbows). For the latter, use kts.DropHeld instead.
kts.Drop
and kts.Can_Drop
are usually used as the action
and possible
functions (respectively) of a Control.
The standard "Drop Gem" control is implemented using this function: see controls.lua. Note that since gems have max_stack
equal to 1, this control only drops one gem at a time.