Skip to main content

ItemRef

The inventory interface

Properties

name

ItemRef.name: string

Get the name associated with the item type

type

ItemRef.type: string

Get the type identifier string

count

ItemRef.count: number

Get/Set the item count

level

ItemRef.level: number

Get/Set the item level

group

ItemRef.group: string

Get/Set the item group

group_secondary

ItemRef.group_secondary: string

Get/Set the secondary item group

element

ItemRef.element: string

Get/Set the item element

quest

ItemRef.quest: bool

Get/Set the quest flag

Items with this flag are required for game progression.

upgrade

ItemRef.upgrade: bool

Get/Set the upgrade flag

Items with this flag mark an upgrade.

skill

ItemRef.skill: bool

Get/Set the skill flag

Items with this flag mark a character skill.

temporary

ItemRef.temporary: bool

Get/Set the temporary flag

Items with this flag are supposed to be cleared after a stage.

display_bar

ItemRef.display_bar: bool

Get/Set the display bar flag

Items with this flag set get displayed in the item bar of the interface.

durability_time

ItemRef.durability_time: bool

Get/Set the durability time flag

Items with this flag loose durability for seconds elapsed

display_char

ItemRef.display_char: string

Get/Set the item fallback display character

display_col

ItemRef.display_col: table

Get/Set the item display color

pickup_sound

ItemRef.pickup_sound: string

Get/Set the path to the sound that gets played on item pickup

count_used

ItemRef.count_used: number

Get/Set the item used count

The count gets increased per use and is supposed to be permanent.

durability

ItemRef.durability: number

Get/Set the item durability attribute value.

Functions

reset

ItemRef:reset() → ()

Reset the item to generated default values with a count of zero.

add

ItemRef:add(
valuenumber | nil--

amount to add (default 1)

) → ()

Add a given count to the item

use

ItemRef:use(
valuenumber | nil--

amount to use (default 1)

) → bool--

success

Attempt to reduce the item count by the given value.

When enough items are held, subtract the count by the given value, add the count to the used counter, and return true.

When not enough items are held, do nothing and return false.

remove

ItemRef:remove(
valuenumber | nil--

amount to remove (default 1)

) → bool--

success

Remove at maximum the given value from the item count.

When not enough items are held, reduce the item count to zero and return false.

When enough items are held, subtract the count by the given value and return true.

The used counter is not updated.

durability_drain

ItemRef:durability_drain(
amountnumber | nil--

drain amount (default all)

) → ()

Drain the item durability by the given amount.

attr_get

Item
ItemRef:attr_get(
keystring--

attribute identifier

) → number | string | table | nil--

value

Get the value of an item attribute

attr_set_int

Item
ItemRef:attr_set_int(
keystring,--

attribute identifier

valuenumber--

value to set

) → ()

Set the value of an item attribute to an integer

attr_set_float

Item
ItemRef:attr_set_float(
keystring,--

attribute identifier

valuenumber--

value to set

) → ()

Set the value of an item attribute to a float

attr_set_string

Item
ItemRef:attr_set_string(
keystring,--

attribute identifier

valuestring--

value to set

) → ()

Set the value of an item attribute to a string

Show raw api
{
    "functions": [
        {
            "name": "reset",
            "desc": "Reset the item to generated default values with a count of zero.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 146,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "add",
            "desc": "Add a given count to the item",
            "params": [
                {
                    "name": "value",
                    "desc": "amount to add (default 1)",
                    "lua_type": "number|nil"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 153,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "use",
            "desc": "Attempt to reduce the item count by the given value.\n\nWhen enough items are held, subtract the count by the given value, add the\ncount to the used counter, and return true.\n\nWhen not enough items are held, do nothing and return false.",
            "params": [
                {
                    "name": "value",
                    "desc": "amount to use (default 1)",
                    "lua_type": "number|nil"
                }
            ],
            "returns": [
                {
                    "desc": "success",
                    "lua_type": "bool"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 167,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "remove",
            "desc": "Remove at maximum the given value from the item count.\n\nWhen not enough items are held, reduce the item count to zero and return\nfalse.\n\nWhen enough items are held, subtract the count by the given value and return\ntrue.\n\nThe used counter is not updated.",
            "params": [
                {
                    "name": "value",
                    "desc": "amount to remove (default 1)",
                    "lua_type": "number|nil"
                }
            ],
            "returns": [
                {
                    "desc": "success",
                    "lua_type": "bool"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 184,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "durability_drain",
            "desc": "Drain the item durability by the given amount.",
            "params": [
                {
                    "name": "amount",
                    "desc": "drain amount (default all)",
                    "lua_type": "number|nil"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 199,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "attr_get",
            "desc": "Get the value of an item attribute",
            "params": [
                {
                    "name": "key",
                    "desc": "attribute identifier",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "value",
                    "lua_type": "number|string|table|nil"
                }
            ],
            "function_type": "method",
            "tags": [
                "Item"
            ],
            "source": {
                "line": 209,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "attr_set_int",
            "desc": "Set the value of an item attribute to an integer",
            "params": [
                {
                    "name": "key",
                    "desc": "attribute identifier",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "value to set",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "Item"
            ],
            "source": {
                "line": 220,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "attr_set_float",
            "desc": "Set the value of an item attribute to a float",
            "params": [
                {
                    "name": "key",
                    "desc": "attribute identifier",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "value to set",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "Item"
            ],
            "source": {
                "line": 230,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "attr_set_string",
            "desc": "Set the value of an item attribute to a string",
            "params": [
                {
                    "name": "key",
                    "desc": "attribute identifier",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "value to set",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "Item"
            ],
            "source": {
                "line": 240,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "name",
            "desc": "Get the name associated with the item type",
            "lua_type": "string",
            "source": {
                "line": 13,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "type",
            "desc": "Get the type identifier string",
            "lua_type": "string",
            "source": {
                "line": 20,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "count",
            "desc": "Get/Set the item count",
            "lua_type": "number",
            "source": {
                "line": 27,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "level",
            "desc": "Get/Set the item level",
            "lua_type": "number",
            "source": {
                "line": 34,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "group",
            "desc": "Get/Set the item group",
            "lua_type": "string",
            "source": {
                "line": 41,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "group_secondary",
            "desc": "Get/Set the secondary item group",
            "lua_type": "string",
            "source": {
                "line": 48,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "element",
            "desc": "Get/Set the item element",
            "lua_type": "string",
            "source": {
                "line": 55,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "quest",
            "desc": "Get/Set the quest flag\n\nItems with this flag are required for game progression.",
            "lua_type": "bool",
            "source": {
                "line": 64,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "upgrade",
            "desc": "Get/Set the upgrade flag\n\nItems with this flag mark an upgrade.",
            "lua_type": "bool",
            "source": {
                "line": 73,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "skill",
            "desc": "Get/Set the skill flag\n\nItems with this flag mark a character skill.",
            "lua_type": "bool",
            "source": {
                "line": 83,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "temporary",
            "desc": "Get/Set the temporary flag\n\nItems with this flag are supposed to be cleared after a stage.",
            "lua_type": "bool",
            "source": {
                "line": 92,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "display_bar",
            "desc": "Get/Set the display bar flag\n\nItems with this flag set get displayed in the item bar of the interface.",
            "lua_type": "bool",
            "source": {
                "line": 101,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "durability_time",
            "desc": "Get/Set the durability time flag\n\nItems with this flag loose durability for seconds elapsed",
            "lua_type": "bool",
            "source": {
                "line": 110,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "display_char",
            "desc": "Get/Set the item fallback display character",
            "lua_type": "string",
            "source": {
                "line": 117,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "display_col",
            "desc": "Get/Set the item display color",
            "lua_type": "table",
            "source": {
                "line": 124,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "pickup_sound",
            "desc": "Get/Set the path to the sound that gets played on item pickup",
            "lua_type": "string",
            "source": {
                "line": 131,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "count_used",
            "desc": "Get/Set the item used count\n\nThe count gets increased per use and is supposed to be permanent.",
            "lua_type": "number",
            "source": {
                "line": 140,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        },
        {
            "name": "durability",
            "desc": "Get/Set the item durability attribute value.",
            "lua_type": "number",
            "source": {
                "line": 193,
                "path": "../../res/data/script/lib/system/item_ref.lua"
            }
        }
    ],
    "types": [],
    "name": "ItemRef",
    "desc": "The inventory interface",
    "source": {
        "line": 5,
        "path": "../../res/data/script/lib/system/item_ref.lua"
    }
}