Item
Item is one of the basic elements in a project, which can be placed on the map or held by units.
Functions
remove
Delete item.
item:remove()
drop_to_point
Drop item to point.
Parameters
Variable | Type | Description |
---|---|---|
point | point | Target point. |
count | number | Number. |
item:drop_to_point(point, count)
transfer_to_point
Move item to point.
Parameter
Variable | Type | Description |
---|---|---|
point | point | Target point. |
item: transfer_to_point(point)
set_name
Set the name of the item.
Parameter
Variable | Type | Description |
---|---|---|
name | str | Item name. |
item:set_name(name)
set_description
Set item description.
Parameter
Variable | Type | Description |
---|---|---|
description | str | Description. |
item:set_description(description)
set_icon
Set the item's icon.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:set_icon(picture_id)
set_creator
Set owning player.
Parameter
Variable | Type | Description |
---|---|---|
player | player | Player. |
item:set_creator(player)
set_level
Set level.
Parameter
Variable | Type | Description |
---|---|---|
level | number | Item level. |
item:set_level(level)
set_charges
Set the number of charges.
Parameter
Variable | Type | Description |
---|---|---|
charge | number | Charge number. |
item:set_charges(charge)
add_charges
Increase the number of charges.
Parameter
Variable | Type | Description |
---|---|---|
charge | number | Charge number. |
item:add_charges(charge)
set_max_charges
Set the maximum number of charges.
Parameter
Variable | Type | Description |
---|---|---|
charge | number | Charge number. |
item:set_max_charges(charge)
set_stacks
Set the number of stacks.
Parameter
Variable | Type | Description |
---|---|---|
stack | number | Stack number. |
item:set_stacks(stack)
add_stacks
Increase the number of stacks.
Parameter
Variable | Type | Description |
---|---|---|
stack | number | Stack number. |
item:add_stacks(stack)
set_basic_attributes
Set basic properties.
Parameters
Variable | Type | Description |
---|---|---|
key | str | Attribute name. |
value | number | Attribute value. |
item:set_basic_attributes(key, value)
add_basic_attributes
Increase basic attributes.
Parameters
Variable | Type | Description |
---|---|---|
key | str | Attribute name. |
value | number | Attribute value. |
item:add_basic_attributes(key, value)
set_hp
Set health.
Parameter
Variable | Type | Description |
---|---|---|
value | number | Life value. |
item:set_hp(value)
add_passive_ability
Add passive skills to items.
Parameters
Variable | Type | Description |
---|---|---|
ability_id | number | Skill type ID. |
level | number | Skill level. |
item:add_passive_ability(ability_id, level)
set_droppable
Set discard status.
Parameter
Variable | Type | Description |
---|---|---|
state | bool | Whether the item can be discarded. |
item:set_droppable(state)
add_tag
Add tag.
Parameter
Variable | Type | Description |
---|---|---|
tag | str | Tag name. |
item:add_tag(tag)
remove_tag
Delete label.
Parameter
Variable | Type | Description |
---|---|---|
tag | str | Tag name. |
item:remove_tag(tag)
set_sale_state
Set whether the item can be sold.
Parameter
Variable | Type | Description |
---|---|---|
state | bool | Whether the item can be sold. |
item:set_sale_state(state)
set_scale
Set item scaling.
Parameter
Variable | Type | Description |
---|---|---|
scale | number | Scale. |
item:set_scale(scale)
set_direction
Set item orientation.
Parameter
Variable | Type | Description |
---|---|---|
direction | number | Item orientation. |
item:set_direction(direction)
create_item_at_point
Create items to point.
Parameters
Variable | Type | Description |
---|---|---|
point | point | Target point. |
item_id | number | Item type ID. |
player | player | Player the item belongs to. |
item.create_item_at_point(point, item_id, player)
add_item_to_unit
Unit add items.
Parameters
Variable | Type | Description |
---|---|---|
unit | unit | Target unit. |
item_id | number | Item type ID. |
item.add_item_to_unit(unit, item_id)
remove_item_from_unit
Unit removes items.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. remove_item_from_unit(unit, item_id)
transfer_item_to_unit
Transfer item type1 item column type2 backpack column.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. transfer_item_to_unit(unit, item, type, position, is_move)
check_item_key_precondition
Check item type preconditions.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. check_item_key_precondition(player, item)
has_tag
Presence tag.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:has_tag(tag)
is_in_scene
Whether it is in the scene.
item:is_in_scene()
is_in_bar
Whether the item is in inventory.
item:is_in_bar()
is_in_bag
Whether the item is in inventory.
item:is_in_bag()
get_last_created_item
Recently created items
item. get_last_created_item()
get_item_buy_price
Get item purchase price.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. get_item_buy_price(type_id, key)
get_item_sell_price
Get the sale price of the item.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. get_item_sell_price(type_id, key)
get_item_group_in_area
Get all items in the area.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. get_item_group_in_area(area)
get_item_type_name
Get item type name.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item. get_item_type_name(type_id)
get_icon_id_by_item_type
Get the image ID of the icon of the item type.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item.get_icon_id_by_item_type(type_id)
get_item_description_by_type
Get the description of the item type.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item.get_item_description_by_type(type_id)
get_type
Get item type.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_type()
get_owner
Get item owner.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_owner()
get_position
Get item location.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_position()
get_stacks
Get item stack count.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_stacks()
get_charges
Get item charges.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_charges()
get_max_charge
Get the maximum charge.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_max_charge()
get_level
Get item level.
item:get_level()
get_hp
Get the health of an item.
item:get_hp()
get_basic_attributes
Get the basic properties of the item.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_basic_attributes(type, key)
get_name
Get item name.
item: get_name()
get_description
Get item description.
item:get_description()
get_scale
Get item scale.
item:get_scale()
get_direction
Get the orientation of the item.
item:get_direction()
get_positive_ability
Active skills for acquiring items.
item:get_positive_ability()
get_passive_ability
Passive ability to acquire items.
Parameter
Variable | Type | Description |
---|---|---|
picture_id | number | Picture ID. |
item:get_passive_ability(index)
get_item_slot_index
Get the grid position of the item on the unit.
item:get_item_slot_index()
get_creator
The owning player who gets the item.
item:get_creator()
get_item_slot_type
Get the inventory slot type of the item on the unit.
item:get_item_slot_type()
item_that_triggered_current_event
The item that triggered the current event.
Parameter
Variable | Type | Description |
---|---|---|
data | table | Event data. |
Return value
Type | Description |
---|---|
item | Item that triggered the current event. |
item.item_that_triggered_current_event(data)
unit_gains_item
Items obtained by the unit.
Return value
Type | Description |
---|---|
item | Item obtained. |
item.unit_gains_item()
unit_loses_item
Unit lost item.
Return value
Type | Description |
---|---|
item | Lost item. |
item.unit_loses_item()
unit_uses_item
Items used by the unit.
Return value
Type | Description |
---|---|
item | Item being used. |
item.unit_uses_item()
item_whose_stack_changed
Items with varying stacks.
Return value
Type | Description |
---|---|
item | Item whose stack number changes. |
item.item_whose_stack_changed()
item_whose_charge_changed
Items that change charge.
Return value
Type | Description |
---|---|
item | Item whose charge changes. |
item.item_whose_charge_changed()
item_purchased
Buy items.
Return value
Type | Description |
---|---|
item | Purchased item. |
item.item_purchased()
item_sold
Sale items.
Return value
Type | Description |
---|---|
item | Item being sold. |
item.item_sold()
Events
Item triggers need to be contained in a group to use group variables.
Item created
Item creation event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item created" , function ( data )
print ( "Item creation event" )
end )
Item created as collection
Items are collected and created.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item created as collection" , function ( data )
print ( "Items were collected and created" )
end )
Item pick up
Item acquisition event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item pick up" , function ( data )
print ( "item acquisition event" )
end )
Item lose
Item lost event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item lose" , function ( data )
print ( "Item lost event" )
end )
Item used
Item use event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item used" , function ( data )
print ( "Item use event" )
end )
Item in bag
Item enters backpack event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item in bag" , function ( data )
print ( "Item enters backpack event" )
end )
Item remove bag
Item leaving inventory slot event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item remove bag" , function ( data )
print ( "Item left inventory event" )
end )
Item in item bar
Item enters inventory event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item in item bar" , function ( data )
print ( "Item enters inventory event" )
end )
Item remove item bar
Item leaves inventory event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item remove item bar" , function ( data )
print ( "Item leaves inventory event" )
end )
Item stack changed
Item change layer event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item stack changed" , function ( data )
print ( "Item change layer event" )
end )
Item charge changed
Item change charge event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item charge changed" , function ( data )
print ( "Item Change Charge Event" )
end )
Item destroy
Item destruction event.
local item_group = cli.item.create_item_trigger_group ( 100001 )
item_group . add_trigger ( "Item destroy" , function ( data )
print ( "Item destruction event" )
end )