From ac5b6ca488413a8d77df6320512b06ef5bbaaf1b Mon Sep 17 00:00:00 2001 From: varttist Date: Sat, 20 Jun 2026 22:20:35 +0300 Subject: [PATCH] Splitting `NodeDefinition` into settings and callbacks, updating annotations to 5.16 --- definitions/NodeDefinition.lua | 662 +---------------------- definitions/NodeDefinition/Callbacks.lua | 193 +++++++ definitions/NodeDefinition/Settings.lua | 484 +++++++++++++++++ definitions/TileAnimationDefinition.lua | 40 +- definitions/TileDefinition.lua | 43 +- 5 files changed, 698 insertions(+), 724 deletions(-) create mode 100644 definitions/NodeDefinition/Callbacks.lua create mode 100644 definitions/NodeDefinition/Settings.lua diff --git a/definitions/NodeDefinition.lua b/definitions/NodeDefinition.lua index ce23858..8cab2c1 100644 --- a/definitions/NodeDefinition.lua +++ b/definitions/NodeDefinition.lua @@ -1,651 +1,11 @@ ---- @meta - - ---- @class NodeDefinition: ItemDefinition -local NodeDefinition = { - - --- For last version see ["Node drawtypes"](https://api.luanti.org/nodes/#node-drawtypes) - --- - --- There are a bunch of different looking node types. - --- * `normal` - --- * * A node-sized cube. - --- * `airlike` - --- * * Invisible, uses no texture. - --- * `liquid` - --- * * The cubic source node for a liquid. - --- * * Faces bordering to the same node are never rendered. - --- * * Connects to node specified in `liquid_alternative_flowing` if specified. - --- * * Use `backface_culling = false` for the tiles you want to make - --- visible when inside the node. - --- * `flowingliquid` - --- * * The flowing version of a liquid, appears with various heights and slopes. - --- * * Faces bordering to the same node are never rendered. - --- * * Connects to node specified in `liquid_alternative_source`. - --- * * You *must* set `liquid_alternative_flowing` to the node's own name. - --- * * Node textures are defined with `special_tiles` where the first tile - --- is for the top and bottom faces and the second tile is for the side - --- faces. - --- * * `tiles` is used for the item/inventory/wield image rendering. - --- * * Use `backface_culling = false` for the special tiles you want to make - --- visible when inside the node - --- * `glasslike` - --- * * Often used for partially-transparent nodes. - --- * * Only external sides of textures are visible. - --- * `glasslike_framed` - --- * * All face-connected nodes are drawn as one volume within a surrounding - --- frame. - --- * * The frame appearance is generated from the edges of the first texture - --- specified in `tiles`. The width of the edges used are 1/16th of texture - --- size: 1 pixel for 16x16, 2 pixels for 32x32 etc. - --- * * The glass 'shine' (or other desired detail) on each node face is supplied - --- by the second texture specified in `tiles`. - --- * `glasslike_framed_optional` - --- * * This switches between the above 2 drawtypes according to the menu setting - --- 'Connected Glass'. - --- * `allfaces` - --- * * Often used for partially-transparent nodes. - --- * * External sides of textures, and unlike other drawtypes, the external sides - --- of other nodes, are visible from the inside. - --- * `allfaces_optional` - --- * * Often used for leaves nodes. - --- * * This switches between `normal`, `glasslike` and `allfaces` according to - --- the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves. - --- * * With 'Simple Leaves' selected, the texture specified in `special_tiles` - --- is used instead, if present. This allows a visually thicker texture to be - --- used to compensate for how `glasslike` reduces visual thickness. - --- * `torchlike` - --- * * A single vertical texture. - --- * * If `paramtype2="[color]wallmounted"`: - --- * * * If placed on top of a node, uses the first texture specified in `tiles`. - --- * * * If placed against the underside of a node, uses the second texture - --- specified in `tiles`. - --- * * * If placed on the side of a node, uses the third texture specified in - --- `tiles` and is perpendicular to that node. - --- * * If `paramtype2="none"`: - --- * * * Will be rendered as if placed on top of a node (see - --- above) and only the first texture is used. - --- * `signlike` - --- * * A single texture parallel to, and mounted against, the top, underside or - --- side of a node. - --- * * If `paramtype2="[color]wallmounted"`, it rotates according to `param2` - --- * * If `paramtype2="none"`, it will always be on the floor. - --- * `plantlike` - --- * * Two vertical and diagonal textures at right-angles to each other. - --- * * See `paramtype2 = "meshoptions"` above for other options. - --- * `firelike` - --- * * When above a flat surface, appears as 6 textures, the central 2 as - --- `plantlike` plus 4 more surrounding those. - --- * * If not above a surface the central 2 do not appear, but the texture - --- appears against the faces of surrounding nodes if they are present. - --- * `fencelike` - --- * * A 3D model suitable for a wooden fence. - --- * * One placed node appears as a single vertical post. - --- * * Adjacently-placed nodes cause horizontal bars to appear between them. - --- * `raillike` - --- * * Often used for tracks for mining carts. - --- * * Requires 4 textures to be specified in `tiles`, in order: Straight, - --- curved, t-junction, crossing. - --- * * Each placed node automatically switches to a suitable rotated texture - --- determined by the adjacent `raillike` nodes, in order to create a - --- continuous track network. - --- * * Becomes a sloping node if placed against stepped nodes. - --- * `nodebox` - --- * * Often used for stairs and slabs. - --- * * Allows defining nodes consisting of an arbitrary number of boxes. - --- * * See [Node boxes] below for more information. - --- * `mesh` - --- * * Uses models for nodes. - --- * * Tiles should hold model materials textures. - --- * * Only static meshes are implemented. - --- * * For supported model formats see Irrlicht engine documentation. - --- * `plantlike_rooted` - --- * * Enables underwater `plantlike` without air bubbles around the nodes. - --- * * Consists of a base cube at the coordinates of the node plus a - --- `plantlike` extension above - --- * * If `paramtype2="leveled", the `plantlike` extension has a height - --- of `param2 / 16` nodes, otherwise it's the height of 1 node - --- * * If `paramtype2="wallmounted"`, the `plantlike` extension - --- will be at one of the corresponding 6 sides of the base cube. - --- Also, the base cube rotates like a `normal` cube would - --- * * The `plantlike` extension visually passes through any nodes above the - --- base cube without affecting them. - --- * * The base cube texture tiles are defined as normal, the `plantlike` - --- extension uses the defined special tile, for example: - --- `special_tiles = {{name = "default_papyrus.png"}},` - --- - --- `*_optional` drawtypes need less rendering time if deactivated(always client-side). - --- - --- @type string? - drawtype = "normal", - - --- Supported for drawtypes "plantlike", "signlike", "torchlike", - --- "firelike", "mesh", "nodebox", "allfaces". - --- For plantlike and firelike, the image will start at the bottom of the - --- node. For torchlike, the image will start at the surface to which the - --- node "attaches". For the other drawtypes the image will be centered - --- on the node. - --- @type number? - visual_scale = 1.0, - - --- {tile definition 1, def2, def3, def4, def5, def6} - --- - --- Textures of node; +Y, -Y, +X, -X, +Z, -Z - --- List can be shortened to needed length. - --- @type (string[]|TileDefinition[])? - tiles = nil, - - --- {tile definition 1, def2, def3, def4, def5, def6} - --- - --- Same as `tiles`, but these textures are drawn on top of the base - --- tiles. You can use this to colorize only specific parts of your - --- texture. If the texture name is an empty string, that overlay is not - --- drawn. Since such tiles are drawn twice, it is not recommended to use - --- overlays on very common nodes. - --- @type (string[]|TileDefinition[])? - overlay_tiles = nil, - - --- {tile definition 1, Tile definition 2}, - --- Special textures of node; used rarely. - --- List can be shortened to needed length. - --- @type (string[]|TileDefinition[])? - special_tiles = nil, - - --- The node's original color will be multiplied with this color. - --- If the node has a palette, then this setting only has an effect in - --- the inventory and on the wield item. - --- @see ColorSpec - --- @type (string|ColorSpec)? - color = '', - - --- Specifies how the texture's alpha channel will be used for rendering. - --- possible values: - --- * "opaque": Node is rendered opaque regardless of alpha channel - --- * "clip": A given pixel is either fully see-through or opaque - --- depending on the alpha channel being below/above 50% in value - --- * "blend": The alpha channel specifies how transparent a given pixel - --- of the rendered node is - --- The default is "opaque" for drawtypes normal, liquid and flowingliquid; - --- "clip" otherwise. - --- If set to a boolean value (deprecated): true either sets it to blend - --- or clip, false sets it to clip or opaque mode depending on the drawtype. - --- @type string? - use_texture_alpha = "opaque", - - --- The node's `param2` is used to select a pixel from the image. - --- Pixels are arranged from left to right and from top to bottom. - --- The node's color will be multiplied with the selected pixel's color. - --- Tiles can override this behavior. - --- Only when `paramtype2` supports palettes. - --- @type string? - palette = "", - - --- Screen tint if player is inside node, see "ColorSpec" - --- @type string? - post_effect_color = "#00000000", - - --- See "Nodes" - --- @type string? - paramtype = "none", - - --- See "Nodes" - --- @type string? - paramtype2 = "none", - - --- Value for param2 that is set when player places node - --- @type number? - place_param2 = 0, - - --- If false, the cave generator and dungeon generator will not carve - --- through this node. - --- Specifically, this stops mod-added nodes being removed by caves and - --- dungeons when those generate in a neighbor mapchunk and extend out - --- beyond the edge of that mapchunk. - --- @type boolean? - is_ground_content = true, - - --- If true, sunlight will go infinitely through this node - --- @type boolean? - sunlight_propagates = false, - - --- If true, objects collide with node - --- @type boolean? - walkable = true, - - --- If true, can be pointed at - --- @type boolean? - pointable = true, - - --- If false, can never be dug - --- @type boolean? - diggable = true, - - --- If true, can be climbed on like a ladder - --- @type boolean? - climbable = false, - - --- Slows down movement of players through this node (max. 7). - --- If this is nil, it will be equal to liquid_viscosity. - --- Note: If liquid movement physics apply to the node - --- (see `liquid_move_physics`), the movement speed will also be - --- affected by the `movement_liquid_*` settings. - --- @type number? - move_resistance = 0, - - --- If true, placed nodes can replace this node - --- @type boolean? - buildable_to = false, - - --- If true, liquids flow into and replace this node. - --- Warning: making a liquid node 'floodable' will cause problems. - --- @type boolean? - floodable = false, - - --- specifies liquid flowing physics - --- * "none": no liquid flowing physics - --- * "source": spawns flowing liquid nodes at all 4 sides and below; - --- recommended drawtype: "liquid". - --- * "flowing": spawned from source, spawns more flowing liquid nodes - --- around it until `liquid_range` is reached; - --- will drain out without a source; - --- recommended drawtype: "flowingliquid". - --- If it's "source" or "flowing", then the - --- `liquid_alternative_*` fields _must_ be specified - --- @type string? - liquidtype = "none", - - --- These fields may contain node names that represent the - --- flowing version (`liquid_alternative_flowing`) and - --- source version (`liquid_alternative_source`) of a liquid. - --- - --- Specifically, these fields are required if any of these is true: - --- * `liquidtype ~= "none" or - --- * `drawtype == "liquid" or - --- * `drawtype == "flowingliquid" - --- - --- Liquids consist of up to two nodes: source and flowing. - --- - --- There are two ways to define a liquid: - --- 1) Source node and flowing node. This requires both fields to be - --- specified for both nodes. - --- 2) Standalone source node (cannot flow). `liquid_alternative_source` - --- must be specified and `liquid_range` must be set to 0. - --- - --- Example: - --- liquid_alternative_flowing = "example:water_flowing", - --- liquid_alternative_source = "example:water_source", - --- @type string? - liquid_alternative_flowing = "", - - --- These fields may contain node names that represent the - --- flowing version (`liquid_alternative_flowing`) and - --- source version (`liquid_alternative_source`) of a liquid. - --- - --- Specifically, these fields are required if any of these is true: - --- * `liquidtype ~= "none" or - --- * `drawtype == "liquid" or - --- * `drawtype == "flowingliquid" - --- - --- Liquids consist of up to two nodes: source and flowing. - --- - --- There are two ways to define a liquid: - --- 1) Source node and flowing node. This requires both fields to be - --- specified for both nodes. - --- 2) Standalone source node (cannot flow). `liquid_alternative_source` - --- must be specified and `liquid_range` must be set to 0. - --- - --- Example: - --- liquid_alternative_flowing = "example:water_flowing", - --- liquid_alternative_source = "example:water_source", - --- @type string? - liquid_alternative_source = "", - - --- Controls speed at which the liquid spreads/flows (max. 7). - --- 0 is fastest, 7 is slowest. - --- By default, this also slows down movement of players inside the node - --- (can be overridden using `move_resistance`) - --- @type number? - liquid_viscosity = 0, - - --- If true, a new liquid source can be created by placing two or more - --- sources nearby - --- @type boolean? - liquid_renewable = true, - - --- specifies movement physics if inside node - --- * false: No liquid movement physics apply. - --- * true: Enables liquid movement physics. Enables things like - --- ability to "swim" up/down, sinking slowly if not moving, - --- smoother speed change when falling into, etc. The `movement_liquid_*` - --- settings apply. - --- * nil: Will be treated as true if `liquidtype ~= "none"` - --- and as false otherwise. - --- @type boolean? - liquid_move_physics = nil, - - --- Only valid for "nodebox" drawtype with 'type = "leveled"'. - --- Allows defining the nodebox height without using param2. - --- The nodebox height is 'leveled' / 64 nodes. - --- The maximum value of 'leveled' is `leveled_max`. - --- @type number? - leveled = 0, - - --- Maximum value for `leveled` (0-127), enforced in - --- `core.set_node_level` and `core.add_node_level`. - --- Values above 124 might causes collision detection issues. - --- @type number? - leveled_max = 127, - - --- Maximum distance that flowing liquid nodes can spread around - --- source on flat land; - --- maximum = 8; set to 0 to disable liquid flow - --- @type number? - liquid_range = 8, - - --- Player will take this amount of damage if no bubbles are left - --- @type number? - drowning = 0, - - --- If player is inside node, this damage is caused - --- @type number? - damage_per_second = 0, - - --- See "Node boxes" - --- @type table? - node_box = {type = "regular"}, - - --- Used for nodebox nodes with the type == "connected". - --- Specifies to what neighboring nodes connections will be drawn. - --- e.g. `{"group:fence", "default:wood"}` or `"default:stone"` - --- @type string[]? - connects_to = {}, - - --- Tells connected nodebox nodes to connect only to these sides of this - --- node. possible: "top", "bottom", "front", "left", "back", "right" - --- @type string[]? - connect_sides = {}, - - --- File name of mesh when using "mesh" drawtype - --- @type string? - mesh = "", - - --- Custom selection box definition. Multiple boxes can be defined. - --- If "nodebox" drawtype is used and selection_box is nil, then node_box - --- definition is used for the selection box. - --- see [Node boxes] for possibilities - --- @type table? - selection_box = {}, - - --- see [Node boxes] for possibilities - --- Custom collision box definition. Multiple boxes can be defined. - --- If "nodebox" drawtype is used and collision_box is nil, then node_box - --- definition is used for the collision box. - --- @type table? - collision_box = {}, - - --- Support maps made in and before January 2012 - --- @type boolean? - legacy_facedir_simple = false, - --- Support maps made in and before January 2012 - --- @type boolean? - legacy_wallmounted = false, - - --- Valid for drawtypes: - --- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid. - --- 1 - wave node like plants (node top moves side-to-side, bottom is fixed) - --- 2 - wave node like leaves (whole node moves side-to-side) - --- 3 - wave node like liquids (whole node moves up and down) - --- Not all models will properly wave. - --- plantlike drawtype can only wave like plants. - --- allfaces_optional drawtype can only wave like leaves. - --- liquid, flowingliquid drawtypes can only wave like liquids. - --- @type number? - waving = 0, - - --- Definition of node sounds to be played at various events. - --- All fields in this table are optional. - --- @type nil|table - sounds = { - - --- If walkable, played when object walks on it. If node is - --- climbable or a liquid, played when object moves through it - --- @type SimpleSoundSpec? - footstep = nil, - - --- While digging node. - --- If `"__group"`, then the sound will be - --- `{name = "default_dig_", gain = 0.5}` , where `` is the - --- name of the item's digging group with the fastest digging time. - --- In case of a tie, one of the sounds will be played (but we - --- cannot predict which one) - --- Default value: `"__group"` - --- @type nil|SimpleSoundSpec|string - dig = {} or "__group", - - --- Node was dug - --- @type SimpleSoundSpec? - dug = nil, - - --- Node was placed. Also played after falling - --- @type SimpleSoundSpec? - place = nil, - - --- When node placement failed. - --- Note: This happens if the _built-in_ node placement failed. - --- This sound will still be played if the node is placed in the - --- `on_place` callback manually. - --- @type SimpleSoundSpec? - place_failed = nil, - - --- When node starts to fall or is detached - --- @type SimpleSoundSpec? - fall = nil, - }, - - --- Name of dropped item when dug. - --- Default dropped item is the node itself. - --- Using a table allows multiple items, drop chances and item filtering: - --- @type (string|table)? - drop = { - --- Maximum number of item lists to drop. - --- The entries in 'items' are processed in order. For each: - --- Item filtering is applied, chance of drop is applied, if both are - --- successful the entire item list is dropped. - --- Entry processing continues until the number of dropped item lists - --- equals 'max_items'. - --- Therefore, entries should progress from low to high drop chance. - --- @type number - max_items = 1, - --- Examples: - --- ```lua - --- { - --- -- 1 in 1000 chance of dropping a diamond. - --- -- Default rarity is '1'. - --- rarity = 1000, - --- items = {"default:diamond"}, - --- }, - --- { - --- -- Only drop if using an item whose name is identical to one - --- -- of these. - --- tools = {"default:shovel_mese", "default:shovel_diamond"}, - --- rarity = 5, - --- items = {"default:dirt"}, - --- -- Whether all items in the dropped item list inherit the - --- -- hardware coloring palette color from the dug node. - --- -- Default is 'false'. - --- inherit_color = true, - --- }, - --- { - --- -- Only drop if using an item whose name contains - --- -- "default:shovel_" (this item filtering by string matching - --- -- is deprecated, use tool_groups instead). - --- tools = {"~default:shovel_"}, - --- rarity = 2, - --- -- The item list dropped. - --- items = {"default:sand", "default:desert_sand"}, - --- }, - --- { - --- -- Only drop if using an item in the "magicwand" group, or - --- -- an item that is in both the "pickaxe" and the "lucky" - --- -- groups. - --- tool_groups = { - --- "magicwand", - --- {"pickaxe", "lucky"} - --- }, - --- items = {"default:coal_lump"}, - --- }, - --- ``` - items = {}, - }, - - --- Node constructor; called after adding node. - --- Can set up metadata and stuff like that. - --- Not called for bulk node placement (i.e. schematics and `VoxelManip`). - --- Note: Within an on_construct callback, core.set_node can cause an - --- infinite loop if it invokes the same callback. - --- Consider using `core.swap_node()` instead. - --- default: nil - --- @type fun(pos:MapPosition)? - on_construct = nil, - - --- Node destructor; called before removing node. - --- Not called for bulk node placement. - --- default: nil - --- @type fun(pos:MapPosition)? - on_destruct = nil, - - --- Node destructor; called after removing node. - --- Not called for bulk node placement. - --- default: nil - --- @type fun(pos:MapPosition, old_node)? - after_destruct = nil, - - --- Called when a liquid (new_node) is about to flood old_node, if it has - --- `floodable = true` in the nodedef. Not called for bulk node placement - --- (i.e. schematics and `VoxelManip`) or air nodes. If return true the - --- node is not flooded, but on_flood callback will most likely be called - --- over and over again every liquid update interval. - --- Default: nil - --- Warning: making a liquid node 'floodable' will cause problems. - --- @type fun(pos:MapPosition, old_node, new_node)? - on_flood = nil, - - - --- Called when `old_node` is about be converted to an item, but before the - --- node is deleted from the world or the drops are added. This is - --- generally the result of either the node being dug or an attached node - --- becoming detached. - --- `old_meta` are the metadata fields (table) of the node before deletion. - --- drops is a table of `ItemStacks`, so any metadata to be preserved can - --- be added directly to one or more of the dropped items. - --- @see ItemStackMetaRef - --- default: nil - --- @type fun(pos:MapPosition, old_node, new_node, old_meta, drops:ItemStack[])? - preserve_metadata = nil, - - --- Called after constructing node when node was placed using - --- core.item_place_node / core.place_node. - --- If return true no item is taken from itemstack. - --- `placer` may be any valid ObjectRef or nil. - --- default: nil - --- @type fun(pos:MapPosition, placer:Player|ObjectRef|nil, itemstack:ItemStack, pointed_thing:pointed_thing)? - after_place_node = nil, - - --- oldmetadata is in table format. - --- Called after destructing node when node was dug using - --- core.node_dig / core.dig_node. - --- default: nil - --- @type fun(pos:Player, oldnode, oldmetadata, digger:Player|ObjectRef|nil)? - after_dig_node = nil, - - --- Returns true if node can be dug, or false if not. - --- default: nil - --- @type fun(pos:MapPosition, player:Player|ObjectRef|nil)? - can_dig = nil, - - --- default: core.node_punch - --- Called when puncher (an ObjectRef) punches the node at pos. - --- By default calls core.register_on_punchnode callbacks. - --- @type fun(pos:MapPosition, node:NodeTable, puncher:Player|ObjectRef|nil, pointed_thing:pointed_thing)? - on_punch = nil, - - --- default: nil - --- Called when clicker (an ObjectRef) used the 'place/build' key - --- (not necessarily an actual rightclick) - --- while pointing at the node at pos with 'node' being the node table. - --- itemstack will hold clicker's wielded item. - --- Shall return the leftover itemstack. - --- Note: pointed_thing can be nil, if a mod calls this function. - --- This function does not get triggered by clients <=0.4.16 if the - --- "formspec" node metadata field is set. - --- @type (fun(pos:MapPosition, node:NodeTable, clicker:Player|ObjectRef, itemstack:ItemStack, pointed_thing:pointed_thing|nil):ItemStack|nil)? - on_rightclick = core.node_punch, - - --- default: core.node_dig - --- By default checks privileges, wears out item (if tool) and removes node. - --- return true if the node was dug successfully, false otherwise. - --- Deprecated: returning nil is the same as returning true. - --- @type (fun(pos:MapPosition, node:NodeTable, digger:Player): boolean)? - on_dig = nil, - - --- default: nil - --- called by NodeTimers, see core.get_node_timer and NodeTimerRef. - --- elapsed is the total time passed since the timer was started. - --- return true to run the timer for another cycle with the same timeout - --- value. - --- @type (fun(pos:MapPosition, elapsed:number): boolean)? - on_timer = nil, - - --- fields = {name1 = value1, name2 = value2, ...} - --- Called when an UI form (e.g. sign text input) returns data. - --- See core.register_on_player_receive_fields for more info. - --- default: nil - --- @type fun(pos:MapPosition, formname:string, fields:table, sender:Player)? - on_receive_fields = nil, - - --- Called when a player wants to move items inside the inventory. - --- Return value: number of items allowed to move. - --- @type (fun(pos:MapPosition, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): number)? - allow_metadata_inventory_move = nil, - - --- Called when a player wants to put something into the inventory. - --- Return value: number of items allowed to put. - --- Return value -1: Allow and don't modify item count in inventory. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): number)? - allow_metadata_inventory_put = nil, - - --- Called when a player wants to take something out of the inventory. - --- Return value: number of items allowed to take. - --- Return value -1: Allow and don't modify item count in inventory. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): number)? - allow_metadata_inventory_take = nil, - - --- Called after the actual action has happened, according to what was - --- allowed. - --- No return value. - --- @type (fun(pos:MapPosition, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): any)? - on_metadata_inventory_move = nil, - --- Called after the actual action has happened, according to what was - --- allowed. - --- No return value. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): any)? - on_metadata_inventory_put = nil, - --- Called after the actual action has happened, according to what was - --- allowed. - --- No return value. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): any)? - on_metadata_inventory_take = nil, - - --- intensity: 1.0 = mid range of regular TNT. - --- If defined, called when an explosion touches the node, instead of - --- removing the node. - --- @type (fun(pos:MapPosition, intensity:number): any)? - on_blast = nil, - - --- stores which mod actually registered a node - --- If the source could not be determined it contains "??" - --- Useful for getting which mod truly registered something - --- example: if a node is registered as ":othermodname:nodename", - --- nodename will show "othermodname", but mod_origin will say "modname" - --- @type string? - mod_origin = "modname", -} +---@meta + +---The original `NodeDefinition`, described in the Luanti API Reference, +---was split into `NodeDefinition.Settings` and `NodeDefinition.Callbacks`. +--- +---Please look at the fields and methods in the corresponding classes. +--- +---This `NodeDefinition` class is a combination of `NodeDefinition.Settings` +---and `NodeDefinition.Callbacks` and to some extent corresponds to the original. +---@class NodeDefinition: NodeDefinition.Settings, NodeDefinition.Callbacks +local NodeDefinition = {} diff --git a/definitions/NodeDefinition/Callbacks.lua b/definitions/NodeDefinition/Callbacks.lua new file mode 100644 index 0000000..37328cc --- /dev/null +++ b/definitions/NodeDefinition/Callbacks.lua @@ -0,0 +1,193 @@ +---Version: 5.16 +---@meta + +---@class NodeDefinition.Callbacks : ItemDefinition.Callbacks +local Callbacks = {} + +---Node constructor; called after adding node. +--- +---Can set up metadata and stuff like that. +--- +---Not called for bulk node placement (i.e. schematics and VoxelManip). +--- +---Note: Within an `on_construct` callback, `core.set_node` can cause an +---infinite loop if it invokes the same callback. +--- +---Consider using `core.swap_node` instead. +--- +---default: `nil` +---@type fun(pos:MapVector)? +Callbacks.on_construct = nil + +---Node destructor; called before removing node. +--- +---Not called for bulk node placement. +--- +---default: `nil` +---@type fun(pos:MapVector)? +Callbacks.on_destruct = nil + +---Node destructor; called after removing node. +--- +---Not called for bulk node placement. +--- +---default: `nil` +---@type fun(pos:MapVector, oldnode:NodeTable)? +Callbacks.after_destruct = nil + +---Called when a liquid (newnode) is about to flood oldnode, if it has +---`floodable = true` in the nodedef. Not called for bulk node placement +---(i.e. schematics and VoxelManip) or air nodes. If return true the +---node is not flooded, but on_flood callback will most likely be called +---over and over again every liquid update interval. +--- +---Default: `nil` +--- +---**Warning**: making a liquid node 'floodable' will cause problems. +---@type (fun(pos:MapVector, oldnode:NodeTable, newnode:NodeTable):boolean?)? +Callbacks.on_flood = nil + + +---Called when `oldnode` is about be converted to an item, but before the +---node is deleted from the world or the drops are added. This is +---generally the result of either the node being dug or an attached node +---becoming detached. +--- * `pos`: node position +--- * `oldnode`: node table of node before it was deleted +--- * `oldmeta`: metadata of node before it was deleted, as a metadata table +--- * `drops`: a table of `ItemStack`s, so any metadata to be preserved can +--- be added directly to one or more of the dropped items. See [ItemStackMetaRef](lua://ItemStackMetaRef). +--- +---Default: `nil` +---@type fun(pos:MapVector, oldnode:NodeTable, newnode:NodeTable, oldmeta:NodeMetaRef, drops:ItemStack[])? +Callbacks.preserve_metadata = nil + +---Called after constructing node when node was placed using +---`core.item_place_node` / `core.place_node`. +--- +---If return `true` no item is taken from itemstack. +--- +---Default: `nil` +---@type (fun(pos:MapVector, placer:Player|ObjectRef|nil, itemstack:ItemStack, pointed_thing:pointed_thing):boolean?)? +Callbacks.after_place_node = nil + +---Called after destructing the node when node was dug using +---`core.node_dig` / `core.dig_node`. +--- +--- * `pos`: node position +--- * `oldnode`: node table of node before it was dug +--- * `oldmetadata`: metadata of node before it was dug, as a metadata table +--- * `digger`: ObjectRef of digger +--- +---Default: `nil` +---@type fun(pos:Player, oldnode:NodeMetaRef, oldmetadata:NodeMetaRef, digger:Player|ObjectRef|nil)? +Callbacks.after_dig_node = nil + +---Returns `true` if node can be dug, or `false` if not. +--- +---Default: `nil` +---@type (fun(pos:MapVector, player:Player|ObjectRef|nil):boolean)? +Callbacks.can_dig = nil + +---Called when puncher (an ObjectRef) punches the node at pos. +--- +---By default calls `core.register_on_punchnode` callbacks. +--- +---Default: `core.node_punch` +---@type fun(pos:MapVector, node:NodeTable, puncher:Player|ObjectRef, pointed_thing:pointed_thing)? +Callbacks.on_punch = nil + +---Called when clicker (an ObjectRef) used the 'place/build' key +---(not necessarily an actual rightclick) +---while pointing at the node at pos with 'node' being the node table. +--- +---itemstack will hold clicker's wielded item. +--- +---Shall return the leftover itemstack. +--- +---**Note**: pointed_thing can be `nil`, if a mod calls this function. +--- +---Default: `nil` +---@type (fun(pos:MapVector, node:NodeTable, clicker:Player|ObjectRef, itemstack:ItemStack, pointed_thing:pointed_thing?):ItemStack|nil)? +Callbacks.on_rightclick = nil + +---By default checks privileges, wears out item (if tool) and removes node. +--- +---Return `true` if the node was dug successfully, `false` otherwise. +--- +---Deprecated: returning `nil` is the same as returning `true`. +--- +---Default: `core.node_dig` +---@type (fun(pos:MapVector, node:NodeTable, digger:Player):boolean)? +Callbacks.on_dig = nil + +---Called by NodeTimers, see `core.get_node_timer` and [NodeTimerRef](lua://NodeTimerRef). +--- +--- * `elapsed`: total time passed since the timer was started. +--- * `node`: node table (since 5.14) +--- * `timeout`: timeout value of the just ended timer (since 5.14) +--- +---Return `true` to run the timer for another cycle with the same timeout value. +--- +---Default: `nil` +---@type (fun(pos:MapVector, elapsed:number, node:NodeTable, timeout:number):boolean?)? +Callbacks.on_timer = nil + +---Fields = {name1 = value1, name2 = value2, ...} +--- +---Formname should be the empty string; you **must not** use formname. +--- +---Called when an UI form (e.g. sign text input) returns data. +--- +---See `core.register_on_player_receive_fields` for more info. +--- +---Default: `nil` +---@type fun(pos:MapVector, formname:string, fields:table, sender:Player)? +Callbacks.on_receive_fields = nil + +---Called when a player wants to move items inside the inventory. +--- +---Return value: number of items allowed to put. +---@type (fun(pos:MapVector, from_list:string, from_index:integer, to_list:string, to_index:integer, count:integer, player:Player):number)? +Callbacks.allow_metadata_inventory_move = nil + +---Called when a player wants to put something into the inventory. +--- +---Return value: number of items allowed to take. +--- +---Return value -1: Allow and don't modify item count in inventory. +---@type (fun(pos:MapVector, listname:string, index:integer, stack:ItemStack, player:Player):number)? +Callbacks.allow_metadata_inventory_put = nil + +---Called when a player wants to take something out of the inventory. +--- +---Return value: number of items allowed to take. +--- +---Return value -1: Allow and don't modify item count in inventory. +---@type (fun(pos:MapVector, listname:string, index:integer, stack:ItemStack, player:Player):number)? +Callbacks.allow_metadata_inventory_take = nil + +---Called after the actual action has happened, according to what was allowed. +--- +---No return value. +---@type fun(pos:MapVector, from_list:string, from_index:integer, to_list:string, to_index:integer, count:integer, player:Player)? +Callbacks.on_metadata_inventory_move = nil + +---Called after the actual action has happened, according to what was allowed. +--- +---No return value. +---@type fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player)? +Callbacks.on_metadata_inventory_put = nil + +---Called after the actual action has happened, according to what was allowed. +--- +---No return value. +---@type fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player)? +Callbacks.on_metadata_inventory_take = nil + +---If defined, called when an explosion touches the node, instead of +---removing the node. +--- +--- * `intensity`: 1.0 = mid range of regular TNT. +---@type fun(pos:MapVector, intensity:number)? +Callbacks.on_blast = nil diff --git a/definitions/NodeDefinition/Settings.lua b/definitions/NodeDefinition/Settings.lua new file mode 100644 index 0000000..2fa20d1 --- /dev/null +++ b/definitions/NodeDefinition/Settings.lua @@ -0,0 +1,484 @@ +---Version: 5.16 +---@meta + +---@class NodeDefinition.Settings : ItemDefinition.Settings +local Settings = {} + +---@alias Node.Settings.drawtype +---|'normal' +---|'airlike' +---|'liquid' +---|'flowingliquid' +---|'glasslike' +---|'glasslike_framed' +---|'glasslike_framed_optional' +---|'allfaces' +---|'allfaces_optional' +---|'torchlike' +---|'signlike' +---|'plantlike' +---|'firelike' +---|'fencelike' +---|'raillike' +---|'nodebox' +---|'mesh' +---|'plantlike_rooted' + +---See [Node drawtypes](https://api.luanti.org/nodes/#node-drawtypes) +---@type Node.Settings.drawtype? +Settings.drawtype = nil + +---Supported for drawtypes `"plantlike"`, `"signlike"`, `"torchlike"`, +---`"firelike"`, `"mesh"`, `"nodebox"`, `"allfaces"`. +--- +---For plantlike and firelike, the image will start at the bottom of the +---node. For torchlike, the image will start at the surface to which the +---node "attaches". For the other drawtypes the image will be centered +---on the node. +---@type number? +Settings.visual_scale = nil + +---Textures of node: +Y, -Y, +X, -X, +Z, -Z. +--- +---List can be shortened to needed length. +---@type TileDefinition? +Settings.tiles = {} + +---Same as `tiles`, but these textures are drawn on top of the base +---tiles. You can use this to colorize only specific parts of your +---texture. If the texture name is an empty string, that overlay is not +---drawn. Since such tiles are drawn twice, it is not recommended to use +---overlays on very common nodes. +---@type TileDefinition? +Settings.overlay_tiles = nil + +---Special textures of node; used rarely. +--- +---List can be shortened to needed length. +---@type TileDefinition? +Settings.special_tiles = nil + +---The node's original color will be multiplied with this color. +--- +---If the node has a palette, then this setting only has an effect in +---the inventory and on the wield item. +---@type ColorSpec? +Settings.color = nil + +---Specifies how the texture's alpha channel will be used for rendering. +--- +---Possible values: +---* `"opaque"`: +--- Node is rendered opaque regardless of alpha channel. +---* `"clip"`: +--- A given pixel is either fully see-through or opaque +--- depending on the alpha channel being below/above 50% in value. +--- Use this for nodes with fully transparent and fully opaque areas. +---* `"blend"`: +--- The alpha channel specifies how transparent a given pixel +--- of the rendered node is. This comes at a performance cost. +--- Only use this when correct rendering +--- among semitransparent nodes is necessary. +--- +---The default is `"opaque"` for drawtypes normal, liquid and flowingliquid, +---mesh and nodebox or "clip" otherwise. +--- +---If set to a boolean value (deprecated): true either sets it to blend +---or clip, false sets it to clip or opaque mode depending on the drawtype. +---@type 'opaque'|'clip'|'blend' +Settings.use_texture_alpha = nil + +---The node's `param2` is used to select a pixel from the image. +--- +---Pixels are arranged from left to right and from top to bottom. +--- +---The node's color will be multiplied with the selected pixel's color. +--- +---Tiles can override this behavior. +--- +---Only when `paramtype2` supports palettes. +---@type string? +Settings.palette = nil + +---Screen tint if a player is inside this node, see `ColorSpec`. +--- +---Color is alpha-blended over the screen. +---@type ColorSpec? +Settings.post_effect_color = nil + +---Determines whether `post_effect_color` is affected by lighting. +---@type boolean? +Settings.post_effect_color_shaded = nil + +---@alias NodeDefinition.paramtype +---|'light' +---|'none' + +---See [Node paramtypes](https://api.luanti.org/nodes/#node-paramtypes) +---@type NodeDefinition.paramtype? +Settings.paramtype = nil + +---@alias NodeDefinition.paramtype2 +---|'flowingliquid' +---|'wallmounted' +---|'facedir' +---|'4dir' +---|'leveled' +---|'degrotate' +---|'meshoptions' +---|'color' +---|'colorfacedir' +---|'color4dir' +---|'colorwallmounted' +---|'glasslikeliquidlevel' +---|'colordegrotate' +---|'none' + +---See [Node paramtypes](https://api.luanti.org/nodes/#node-paramtypes) +---@type NodeDefinition.paramtype2? +Settings.paramtype2 = nil + +---Value for param2 that is set when player places node. +---@type integer? +Settings.place_param2 = nil + +---If true, place_param2 is nil, and this is a wallmounted node, +---this node might use the special 90° rotation when placed +---on the floor or ceiling, depending on the direction. +--- +---See the explanation about wallmounted for details. +--- +---Otherwise, the rotation is always the same on vertical placement. +---@type boolean? +Settings.wallmounted_rotate_vertical = nil + +---If `false`, the cave generator and dungeon generator will not carve +---through this node. +--- +---Specifically, this stops mod-added nodes being removed by caves and +---dungeons when those generate in a neighbor mapchunk and extend out +---beyond the edge of that mapchunk. +---@type boolean? +Settings.is_ground_content = nil + +---If `true`, sunlight will go infinitely through this node. +---@type boolean? +Settings.sunlight_propagates = nil + +---If `true`, objects collide with node. +---@type boolean? +Settings.walkable = nil + +---Can be `true` if it is pointable, `false` if it can be pointed through, +---or `"blocking"` if it is pointable but not selectable. +--- +---Clients older than 5.9.0 interpret `pointable = "blocking"` as `pointable = true`. +--- +---Can be overridden by the `pointabilities` of the held item. +--- +---A client may be able to point non-pointable nodes, since it isn't checked server-side. +---@type (boolean|'blocking')? +Settings.pointable = nil + +---If `false`, can never be dug. +---@type boolean? +Settings.diggable = nil + +---If `true`, can be climbed on like a ladder. +---@type boolean? +Settings.climbable = nil + +---Slows down movement of players through this node (max. 7). +--- +---If this is nil, it will be equal to liquid_viscosity. +--- +---**Note**: If liquid movement physics apply to the node +---(see `liquid_move_physics`), the movement speed will also be +---affected by the `movement_liquid_*` settings. +---@type integer? +Settings.move_resistance = nil + +---If `true`, placed nodes can replace this node. +---@type boolean? +Settings.buildable_to = nil + +---If `true`, liquids flow into and replace this node. +--- +---**Warning**: making a liquid node `'floodable'` will cause problems. +---@type boolean? +Settings.floodable = nil + +---Specifies liquid flowing physics: +--- * `"none"`: no liquid flowing physics +--- * `"source"`: spawns flowing liquid nodes at all 4 sides and below; +--- recommended drawtype: "liquid". +--- * `"flowing"`: spawned from source, spawns more flowing liquid nodes +--- around it until `liquid_range` is reached; +--- will drain out without a source; +--- recommended drawtype: "flowingliquid". +--- +---If it's "source" or "flowing", then the +---`liquid_alternative_*` fields _must_ be specified +---@type 'nonde'|'source'|'flowing'|nil +Settings.liquidtype = nil + +---These fields may contain node names that represent the +---flowing version (`liquid_alternative_flowing`) and +---source version (`liquid_alternative_source`) of a liquid. +--- +---Specifically, these fields are required if `liquidtype ~= "none"` or +---`drawtype == "flowingliquid"`. +--- +---Liquids consist of up to two nodes: source and flowing. +--- +---There are two ways to define a liquid: +--- 1) Source node and flowing node. This requires both fields to be +--- specified for both nodes. +--- 2) Standalone source node (cannot flow). `liquid_alternative_source` +--- must be specified and `liquid_range` must be set to 0. +--- +---Example: +---``` +--- liquid_alternative_flowing = "example:water_flowing", +--- liquid_alternative_source = "example:water_source", +--- ``` +---@type string? +Settings.liquid_alternative_flowing = nil + +---See `Node.Settings.liquid_alternative_flowing`. +---@type string? +Settings.liquid_alternative_source = nil + +---Controls speed at which the liquid spreads/flows (max. 7). +--- +---0 is fastest, 7 is slowest. +--- +---By default, this also slows down movement of players inside the node +---(can be overridden using `move_resistance`) +---@type integer? +Settings.liquid_viscosity = nil + +---If `true`, a new liquid source can be created by placing two or more +---sources nearby. +---@type boolean? +Settings.liquid_renewable = nil + +---Specifies movement physics if inside node: +--- * `false`: No liquid movement physics apply. +--- * `true`: Enables liquid movement physics. Enables things like +--- ability to "swim" up/down, sinking slowly if not moving, +--- smoother speed change when falling into, etc. The `movement_liquid_*` +--- settings apply. +--- * `nil`: Will be treated as true if `liquidtype ~= "none"` +--- and as false otherwise. +---@type boolean? +Settings.liquid_move_physics = nil + +---Unclear meaning, the engine sets this to true for 'air' and 'ignore' deprecated. +---@type string? +Settings.air_equivalent = nil + +---Only valid for "nodebox" drawtype with 'type = "leveled"'. +--- +---Allows defining the nodebox height without using param2. +--- +---The nodebox height is `leveled` / 64 nodes. +--- +---Integer with range [0, `leveled_max`]. +---@type integer? +Settings.leveled = nil + +---Maximum value for `leveled` (0-127), enforced in +---`core.set_node_level` and `core.add_node_level`. +--- +---Values above 124 might causes collision detection issues. +---@type integer? +Settings.leveled_max = nil + +---Maximum distance that flowing liquid nodes can spread around +---source on flat land; +---maximum = 8; set to 0 to disable liquid flow. +---@type integer? +Settings.liquid_range = nil + +---Player will take this amount of damage if no bubbles are left. +---@type number? +Settings.drowning = nil + +---If player is inside node, this damage is caused. +---@type number? +Settings.damage_per_second = nil + +---@alias NodeDefinition.node_box.box [number, number, number, number, number, number] + +---@alias NodeDefinition.node_box +---|{ type:'regular' } +---|{ type:'fixed', fixed:NodeDefinition.node_box.box|NodeDefinition.node_box.box[] } +---|{ type:'leveled', fixed:NodeDefinition.node_box.box|NodeDefinition.node_box.box[] } +---|{ type:'wallmounted', wall_top:NodeDefinition.node_box.box, wall_bottom:NodeDefinition.node_box.box, wall_side:NodeDefinition.node_box.box } +---|{ +--- type:'connected', +--- fixed:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_top:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_bottom:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_front:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_left:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_back:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- connect_right:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_top:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_bottom:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_front:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_left:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_back:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_right:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +--- disconnected_sides:NodeDefinition.node_box.box|NodeDefinition.node_box.box[], +---} + +---See "Node boxes" +---@type NodeDefinition.node_box? +Settings.node_box = nil + +---Used for nodebox nodes with the type == "connected". +--- +---Specifies to what neighboring nodes connections will be drawn. +---e.g. `{"group:fence", "default:wood"}` or `"default:stone"` +---@type (string|string[])? +Settings.connects_to = nil + +---Tells connected nodebox nodes to connect only to these sides of this node. +---@type 'top'|'bottom'|'front'|'left'|'back'|'right'|nil +Settings.connect_sides = nil + +---File name of mesh when using "mesh" drawtype +---The center of the node is the model origin. +--- +---For legacy reasons, this uses a different scale depending on the mesh: +--- 1. For `glTF` models: 10 units = 1 node (consistent with the scale for entities). +--- 2. For `obj` models: 1 unit = 1 node. +--- 3. For `b3d` and `x` models: 1 unit = 1 node if static, otherwise 10 units = 1 node. +--- +---Using static glTF or obj models is recommended. +--- +---You can use the `visual_scale` multiplier to achieve the expected scale. +---@type string? +Settings.mesh = nil + +---Custom selection box definition. Multiple boxes can be defined. +--- +---If `"nodebox"` drawtype is used and selection_box is `nil`, then node_box +---definition is used for the selection box +---@type NodeDefinition.node_box? +Settings.selection_box = nil + +---Custom collision box definition. Multiple boxes can be defined. +--- +---If `"nodebox"` drawtype is used and collision_box is `nil`, then node_box +---definition is used for the collision box. +---@type NodeDefinition.node_box? +Settings.collision_box = nil + +---Support maps made in and before January 2012 +---@type boolean? +Settings.legacy_facedir_simple = nil + +---Support maps made in and before January 2012 +---@type boolean? +Settings.legacy_wallmounted = nil + +---Valid for drawtypes: +---`mesh`, `nodebox`, `plantlike`, `allfaces_optional`, `liquid`, `flowingliquid`. +--- +---* `1` - wave node like plants (node top moves side-to-side, bottom is fixed) +---* `2` - wave node like leaves (whole node moves side-to-side) +---* `3` - wave node like liquids (whole node moves up and down) +--- +---Not all models will properly wave. +--- +---`plantlike` drawtype can only wave like plants. +--- +---`allfaces_optional` drawtype can only wave like leaves. +--- +---`liquid`, `flowingliquid` drawtypes can only wave like liquids. +---@type number? +Settings.waving = nil + +---Definition of node sounds to be played at various events. +---All fields in this table are optional. +---@class NodeDefinition.sounds_table +--- +---If walkable, played when object walks on it. If node is +---climbable or a liquid, played when object moves through it. +--- +---Sound is played at the base of the object's collision-box. +--- +---Gain is multiplied by `0.6`. +--- +---For local player, it's played position-less, with normal gain. +---@field footstep SimpleSoundSpec? +--- +---While digging node. +--- +---If `"__group"`, then the sound will be +---`{name = "default_dig_", gain = 0.5}` , where `` is the +---name of the item's digging group with the fastest digging time. +--- +---In case of a tie, one of the sounds will be played (but we +---cannot predict which one) +--- +---Default value: `"__group"` +---@field dig SimpleSoundSpec|'__group? +--- +---Node was dug. +---@field dug SimpleSoundSpec? +--- +---Node was placed. Also played after falling +---@field place SimpleSoundSpec? +--- +---When node placement failed. +--- +---**Note**: This happens if the _built-in_ node placement failed. +--- +---This sound will still be played if the node is placed in the +---`on_place` callback manually. +---@field place_failed SimpleSoundSpec? +--- +---When node starts to fall or is detached. +---@field fall SimpleSoundSpec? + +---Definition of node sounds to be played at various events. +--- +---All fields in this table are optional. +---@type NodeDefinition.sounds_table? +Settings.sounds = nil + +---@alias NodeDefinition.drop_table.dropitem_table { +--- rarity:integer, +--- items:string[], +--- tools:string[], +--- inherit_color:boolean, +--- tool_groups:table, +---} + +---Using a table allows multiple items, drop chances and item filtering. +---@class NodeDefinition.drop_table +---@field max_items integer +---@field items NodeDefinition.drop_table.dropitem_table + +---Name of dropped item when dug. +--- +---Default dropped item is the node itself. +--- +---Using a table allows multiple items, drop chances and item filtering. +---@type (NodeDefinition.drop_table|string)? +Settings.drop = nil + +---Stores which mod actually registered a node. +--- +---If the source could not be determined it contains `"??"`. +--- +---Useful for getting which mod truly registered something +---example: if a node is registered as `":othermodname:nodename"`, +---nodename will show `"othermodname"`, but mod_origin will say `"modname"`. +---@type string +Settings.mod_origin = nil diff --git a/definitions/TileAnimationDefinition.lua b/definitions/TileAnimationDefinition.lua index 861d3ed..7f0b09d 100644 --- a/definitions/TileAnimationDefinition.lua +++ b/definitions/TileAnimationDefinition.lua @@ -1,38 +1,6 @@ +---Version: 5.16 --- @meta - ---- @class TileAnimationDefinition: table -local TileAnimationDefinition = { - --- @type string one of {"vertical_frames"|"sheet_2d"} - type = "", - - --- Width of a frame in pixels. - --- Only for `type == "vertical_frames"` - --- @type number - aspect_w = 16, - - --- Height of a frame in pixels - --- Only for `type == "vertical_frames"` - --- @type number - aspect_h = 16, - - --- Full loop length - --- Only for `type == "vertical_frames"` - --- @type number - length = 3.0, - - --- Width in number of frames - --- Only for `type == "sheet_2d"` - --- @type number - frames_w = 5, - - --- Height in number of frames - --- Only for `type == "sheet_2d"` - --- @type number - frames_h = 3, - - --- Length of a single frame - --- Only for `type == "sheet_2d"` - --- @type number - frame_length = 0.5, -} +---@alias TileAnimationDefinition +---|{type:'vertical_frames', aspect_w:integer, aspect_h:integer, length:integer} +---|{type:'sheet_2d', frames_w:integer, frames_h:integer, frame_length:integer} diff --git a/definitions/TileDefinition.lua b/definitions/TileDefinition.lua index be4fc11..9158767 100644 --- a/definitions/TileDefinition.lua +++ b/definitions/TileDefinition.lua @@ -1,39 +1,8 @@ +---Version: 5.16 --- @meta - ---- @class TileDefinition -local TileDefinition = { - --- @type string - name = "image.png", - - --- @type TileAnimationDefinition? - animation = nil, - - --- Backface culling enabled by default for most nodes. - --- @type boolean? - backface_culling = true, - - --- One of `{"node"|"world"|"user"}`. - --- - --- `align_style` determines whether the texture will be rotated with the node or kept aligned with its surroundings. - --- - --- `"user"` means that client setting will be used, similar to `glasslike_framed_optional`. - --- - --- **Note:** supported by solid nodes and nodeboxes only. - --- @type string? - align_style = "none", - - --- `scale` is used to make texture span several (exactly scale) nodes, instead of just one, in each direction. - --- - --- Works for world-aligned textures only. - --- - --- **Note** that as the effect is applied on per-mapblock basis, - --- 16 should be equally divisible by scale or you may get wrong results. - --- @type number? - scale = 1, - - --- - the texture's color will be multiplied with this color. - --- - the tile's color overrides the owning node's color in all cases. - --- @type string|ColorSpec|nil - color = "" -} +---@alias TileDefinition +---|string +---|{name:string, animation:TileAnimationDefinition} +---|{name:string, backface_culling:boolean, align_style:'node'|'world'|'user', scale:integer} +---|{name:string, color:ColorSpec}