kts.SwingOrDrop – attack with melee weapon if possible, drop held item otherwise
kts.SwingOrDrop()
result = kts.Can_SwingOrDrop()
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.
kts.SwingOrDrop
returns nothing, and kts.Can_SwingOrDrop
returns a boolean as described above.
kts.SwingOrDrop
and kts.Can_SwingOrDrop
are useful as the action
and possible
functions of a Control, respectively.
The standard "melee attack" control ("fist" icon) uses this function: see controls.lua.