kts.ItemType

Name

kts.ItemType – create a new ItemType

Synopsis

result = kts.ItemType{
    allow_strength = <boolean>,
    ammo = <item type>,
    backpack_graphic = <graphic>,
    backpack_overdraw = <graphic>,
    backpack_slot = <integer>,
    can_throw = <boolean>,
    control = <control>,
    critical = <boolean or string>,
    fragile = <boolean>,
    graphic = <graphic>,
    key = <integer>,
    max_stack = <integer>,
    melee_action = <function>,
    melee_backswing_time = <integer>,
    melee_damage = <function or integer>,
    melee_downswing_time = <integer>,
    melee_stun_time = <function or integer>,
    melee_tile_damage = <function or integer>,
    missile_access_chance = <number between 0 and 1>,
    missile_anim = <anim>,
    missile_backswing_time = <integer>,
    missile_damage = <function or integer>,
    missile_downswing_time = <integer>,
    missile_hit_multiplier = <integer>,
    missile_range = <integer>,
    missile_speed = <integer>,
    missile_stun_time = <function or integer>,
    on_drop = <function>,
    on_hit = <function>,
    on_pick_up = <function>,
    on_walk_over = <function>,
    open_traps = <boolean>,
    overlay = <overlay>,
    parry_chance = <number between 0 and 1>,
    prefer_sword = <boolean>,
    reload_action = <function>,
    reload_action_time = <integer>,
    reload_time = <integer>,
    stack_graphic = <graphic>,
    tutorial_key = <integer>,
    type = <"held", "backpack", "magic" or "nopickup">
}

Note: all fields are optional – reasonable default values will be used for any nil fields. Most items will need to specify at least type, however.

Description

An "ItemType" represents a "template" for creating items. For example, "axe", "hammer", "gem", and "ancient book of knowledge" are ItemTypes.

The kts.ItemType function creates a new ItemType. The parameter is a table containing various properties that the ItemType should have, as follows:

Return Value

The new ItemType (a Lua userdata object) will be returned.

Errors

There are several different errors that can be generated if any of the input parameters are incorrect.

Examples

Several examples of ItemTypes can be found in the file knights_data/server/classic/items.lua in the Knights distribution.

See Also

kts.Anim

kts.Control

kts.Graphic

kts.Overlay

kts.Tile