Files
smc-luanti-ide-helper/definitions/ItemDefinition/Settings.lua

245 lines
7.8 KiB
Lua

---Version: 5.16
---@meta
---@class ItemDefinition.Settings
local Settings = {}
---Can contain new lines. `"\n"` has to be used as new line character.
---
---See also: `get_description` in [ItemStack](lua://ItemStack).
---@type string?
Settings.description = nil
---Must not contain new lines.
---
---Defaults to `nil`.
---
---Use an [ItemStack](lua://ItemStack) to get the short description, e.g.:
---```
--- ItemStack(itemname):get_short_description()
---```
---@type string?
Settings.short_description = nil
---Table of groups-characteristics of Item.
---```
--- key = name, value = rating; rating = number.
---```
---If rating not applicable, use 1.
---
---e.g.:
---```
--- {wool = 1, fluffy = 3}
--- {soil = 2, outerspace = 1, crumbly = 1}
--- {bendy = 2, snappy = 1},
--- {hard = 1, metal = 1, spikes = 1}
---```
---@type ItemDefinition.Groups?
Settings.groups = nil
---Texture shown in the inventory GUI.
---
---Defaults to a 3D rendering of the node if left empty.
---@type ItemImageDefinition?
Settings.inventory_image = nil
---An overlay texture which is not affected by colorization.
---@type ItemImageDefinition?
Settings.inventory_overlay = nil
---Image shown when item is held in hand.
---
---Defaults to a 3D rendering of the node if left empty.
---@type ItemImageDefinition?
Settings.wield_image = nil
---Like `inventory_overlay` but only used in the same situation as `wield_image`.
---@type ItemImageDefinition?
Settings.wield_overlay = nil
---Scale for the item when held in hand.
---@type Position?
Settings.wield_scale = nil
---An image file containing the palette of a node.
---
---You can set the currently used color as the "palette_index" field of
---the item stack metadata.
---
---The palette is always stretched to fit indices between 0 and 255, to
---ensure compatibility with "colorfacedir" (and similar) nodes.
---@type string?
Settings.palette = nil
---Color the item is colorized with. The palette overrides this.
---
---It is a colorspec.
---@type ColorSpec?
Settings.color = nil
---Maximum amount of items that can be in a single stack.
---
---The default can be changed by the setting `default_stack_max`.
---
---Range: [1, 65535]
---@type integer?
Settings.stack_max = nil
---Range of node and object pointing that is possible with this item held.
---
---Can be overridden with itemstack meta.
---@type number?
Settings.range = nil
---If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
---even those for which `pointable = false`.
---@type boolean?
Settings.liquids_pointable = nil
---@alias ItemDefinition.pointabilities_table.value true|false|"blocking"
---@alias ItemDefinition.pointabilities_table {nodes:table<string, ItemDefinition.pointabilities_table.value>, objects:table<string, ItemDefinition.pointabilities_table.value>}
---Contains lists to override the `pointable` property of nodes and objects.
---
---The index can be a node/entity name or a group with the prefix `"group:"`.
---
---For objects `armor_groups` are used and for players the entity name is irrelevant.)
---
---If multiple fields fit, the following priority order is applied:
--- 1. value of matching node/entity name
--- 2. `true` for any group
--- 3. `false` for any group
--- 4. `"blocking"` for any group
--- 5. `liquids_pointable` if it is a liquid node
--- 6. `pointable` property of the node or object
---@type ItemDefinition.pointabilities_table?
Settings.pointabilities = nil
---When used for nodes: Defines amount of light emitted by node.
---
---Otherwise: Defines texture glow when viewed as a dropped item.
---
---To set the maximum (14), use the value `core.LIGHT_MAX`.
---
---A value outside the range 0 to `core.LIGHT_MAX` causes undefined
---behavior.
---@type number?
Settings.light_source = nil
---@alias ItemDefinition.tool_capabilities_table.groupcaps_table table<string, {times:number[], uses:integer, maxlevel:integer}>
---@class ItemDefinition.tool_capabilities_table
---@field full_punch_interval number
---@field max_drop_level integer
---
---For example:
---```
---{
--- choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
---},
---```
---@field groupcaps ItemDefinition.tool_capabilities_table.groupcaps_table
---
---Damage values are integers [s16]
---@field damage_groups table<string, integer>
---
---Amount of uses this tool has for attacking players and entities
---by punching them (0 = infinite uses).
---
---For compatibility, this is automatically set from the first
---suitable groupcap using the formula "uses * 3^(maxlevel - 1)".
---
---It is recommend to set this explicitly instead of relying on the
---fallback behavior.
---@field punch_attack_uses integer
---See "Tool Capabilities" section for an example including explanation.
---@type ItemDefinition.tool_capabilities_table?
Settings.tool_capabilities = nil
---`Wear Bar` is a property of items that defines the coloring of the bar
---that appears under damaged tools. If it is absent, the default behavior
---of green-yellow-red is used.
---@class ItemDefinition.wearbar_color_table
---
--- * `linear`: blends smoothly between each defined color point.
--- * `constant`: each color starts at its defined point,
--- and continues up to the next point
---@field blend 'constant'|'linear'
---
---Specified as ColorSpec color values assigned to float durability keys.
---
---"Durability" is defined as `1 - (wear / 65535)`.
---@field color_stops table<number, ColorSpec>
---Set wear bar color of the tool by setting color stops and blend mode.
---
---See "Wear Bar Color" section for further explanation including an example.
---@type ItemDefinition.wearbar_color_table|ColorSpec|nil
Settings.wear_color = nil
---If `nil` and item is node, prediction is made automatically.
---
---If `nil` and item is not a node, no prediction is made.
---
---If `""` and item is anything, no prediction is made.
---
---Otherwise should be name of node which the client immediately places
---on ground when the player places the item. Server will always update
---with actual result shortly.
---@type string?
Settings.node_placement_prediction = nil
---If `""`, no prediction is made.
---
---If `"air"`, node is removed.
---
---Otherwise should be name of node which the client immediately places
---upon digging. Server will always update with actual result shortly.
---
---Default: `"air"`
---@type string?
Settings.node_dig_prediction = nil
---Only affects touchscreen clients.
---Defines the meaning of short and long taps with the item in hand.
---If specified as a table, the field to be used is selected according to
---the current `pointed_thing`.
---There are three possible TouchInteractionMode values:
---* "long_dig_short_place" (long tap = dig, short tap = place)
---* "short_dig_long_place" (short tap = dig, long tap = place)
---* "user":
---* * For `pointed_object`: Equivalent to "short_dig_long_place" if the
--- client-side setting "touch_punch_gesture" is "short_tap" (the
--- default value) and the item is able to punch (i.e. has no on_use
--- callback defined).
--- Equivalent to "long_dig_short_place" otherwise.
---* * For `pointed_node` and `pointed_nothing`:
--- Equivalent to "long_dig_short_place".
---* * The behavior of "user" may change in the future.
---The default value is "user".
---
---@type table<string,SimpleSoundSpec>?
Settings.touch_interaction = nil
---@class ItemDefinition.sound_table
---
---When tool breaks due to wear. Ignored for non-tools.
---@field breaks SimpleSoundSpec?
---
---When item is eaten with `core.do_item_eat`.
---@field eat SimpleSoundSpec?
---
---When item is used with the 'punch/dig' key pointing at a node or entity.
---@field punch_use SimpleSoundSpec?
---
---When item is used with the 'punch/dig' key pointing at nothing (air)
---@field punch_use_air SimpleSoundSpec?
---Definition of item sounds to be played at various events.
---
---All fields in this table are optional.
---
---@type ItemDefinition.sound_table?
Settings.sound = nil