kts.SwingOrDrop

Name

kts.SwingOrDrop – attack with melee weapon if possible, drop held item otherwise

Synopsis

kts.SwingOrDrop()

result = kts.Can_SwingOrDrop()

Description

If the current actor (cxt.actor) is a creature who is able to act, and is not currently approaching a square, then calling kts.SwingOrDrop() will cause that creature to begin a melee attack with their currently held weapon, if applicable, or it will cause them to drop their currently held item (as if kts.DropHeld had been called), otherwise.

kts.Can_SwingOrDrop() returns true if the current actor is not currently approaching a square, or false otherwise.

Return Value

kts.SwingOrDrop returns nothing, and kts.Can_SwingOrDrop returns a boolean as described above.

Notes

kts.SwingOrDrop and kts.Can_SwingOrDrop are useful as the action and possible functions of a Control, respectively.

Examples

The standard "melee attack" control ("fist" icon) uses this function: see controls.lua.

See Also

The cxt table

kts.Swing

kts.Throw

kts.ThrowOrShoot