Modern Lua Plugins: ide-helper: core_namespace.lua improvements. LG-1978, LORD-68

This commit is contained in:
alek13
2025-10-01 10:37:20 +03:00
parent 7e9fb601bb
commit 8353863965
2 changed files with 92 additions and 49 deletions

View File

@@ -62,9 +62,9 @@ function InvRef:add_item(list_name, stack) end
function InvRef:room_for_item(list_name, stack) end function InvRef:room_for_item(list_name, stack) end
--- returns true if the stack of items can be fully taken from the list --- returns true if the stack of items can be fully taken from the list
--- @overload fun(list_name:string, stack:ItemStack):boolean --- @overload fun(list_name:string, stack:ItemStack):boolean
--- @param list_name string --- @param list_name string
--- @param stack ItemStack|ItemStackString --- @param stack ItemStack|ItemStackString
--- @param match_meta boolean If `match_meta` is false, only the items' names are compared (default: `false`). --- @param match_meta? boolean If `match_meta` is false, only the items' names are compared (default: `false`).
--- @return boolean --- @return boolean
function InvRef:contains_item(list_name, stack, match_meta) end function InvRef:contains_item(list_name, stack, match_meta) end

View File

@@ -11,10 +11,10 @@
-- --
--- See ./classes/AreaStore.lua --- See ./classes/AreaStore.lua
---@class NodeTable --- @class NodeTable
---@field name string --- @field name string
---@field param1 number --- @field param1 number?
---@field param2 number --- @field param2 number?
NodeTable = {} NodeTable = {}
--- See ./classes/NodeMetaRef.lua --- See ./classes/NodeMetaRef.lua
@@ -63,6 +63,8 @@ core = {}
--- @legacy --- @legacy
minetest = core minetest = core
-- Escape sequences: -- Escape sequences:
--- * `color` is a ColorString --- * `color` is a ColorString
@@ -70,9 +72,10 @@ minetest = core
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3107-L3109) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3107-L3109)
--- ---
--- @param color string @ColorString --- @param color ColorString
--- @return string --- @return string
function minetest.get_color_escape_sequence(color) end function minetest.get_color_escape_sequence(color) end
--- * Equivalent to: --- * Equivalent to:
--- `minetest.get_color_escape_sequence(color) .. --- `minetest.get_color_escape_sequence(color) ..
--- message .. --- message ..
@@ -80,19 +83,21 @@ function minetest.get_color_escape_sequence(color) end
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3110-L3114) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3110-L3114)
--- ---
--- @param color string @ColorString --- @param color ColorString
--- @param message string --- @param message string
--- @return string --- @return string
function minetest.colorize(color, message) end function minetest.colorize(color, message) end
--- * `color` is a ColorString --- * `color` is a ColorString
--- * The escape sequence sets the background of the whole text element to --- * The escape sequence sets the background of the whole text element to
--- `color`. Only defined for item descriptions and tooltips. --- `color`. Only defined for item descriptions and tooltips.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3115-L3118) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3115-L3118)
--- ---
--- @param color string @ColorString --- @param color ColorString
--- @return string --- @return string
function minetest.get_background_escape_sequence(color) end function minetest.get_background_escape_sequence(color) end
--- * Removes foreground colors added by `get_color_escape_sequence`. --- * Removes foreground colors added by `get_color_escape_sequence`.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3119-L3120) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3119-L3120)
@@ -104,7 +109,9 @@ function minetest.strip_foreground_colors(str) end
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3121-L3122) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3121-L3122)
--- ---
--- @param str string --- @param str string
--- @return string
function minetest.strip_background_colors(str) end function minetest.strip_background_colors(str) end
--- * Removes all color escape sequences. --- * Removes all color escape sequences.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3123-L3124) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3123-L3124)
@@ -113,6 +120,8 @@ function minetest.strip_background_colors(str) end
--- @return string --- @return string
function minetest.strip_colors(str) end function minetest.strip_colors(str) end
-- Helpers: -- Helpers:
--- returns a string or table --- returns a string or table
@@ -126,11 +135,12 @@ function minetest.strip_colors(str) end
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3244-L3251) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3244-L3251)
--- ---
--- @param str string --- @param str string
--- @param limit number --- @param limit number
--- @param as_table boolean --- @param as_table? boolean
--- @return string|table --- @return string|table
function minetest.wrap_text(str, limit, as_table) end function minetest.wrap_text(str, limit, as_table) end
--- returns string `"(X,Y,Z)"` --- returns string `"(X,Y,Z)"`
--- * `pos`: table {x=X, y=Y, z=Z} --- * `pos`: table {x=X, y=Y, z=Z}
--- * Converts the position `pos` to a human-readable, printable string --- * Converts the position `pos` to a human-readable, printable string
@@ -143,6 +153,7 @@ function minetest.wrap_text(str, limit, as_table) end
--- @param decimal_places? number --- @param decimal_places? number
--- @return string --- @return string
function minetest.pos_to_string(pos, decimal_places) end function minetest.pos_to_string(pos, decimal_places) end
--- returns a position or `nil` --- returns a position or `nil`
--- * Same but in reverse. --- * Same but in reverse.
--- * If the string can't be parsed to a position, nothing is returned. --- * If the string can't be parsed to a position, nothing is returned.
@@ -152,6 +163,7 @@ function minetest.pos_to_string(pos, decimal_places) end
--- @param string string --- @param string string
--- @return Position --- @return Position
function minetest.string_to_pos(string) end function minetest.string_to_pos(string) end
--- returns two positions --- returns two positions
--- * Converts a string representing an area box into two positions --- * Converts a string representing an area box into two positions
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3260-L3261) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3260-L3261)
@@ -164,26 +176,30 @@ function minetest.string_to_pos(string) end
--- * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})` --- * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
--- returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}` --- returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.6.1/doc/lua_api.txt#L3581-L3590) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.6.1/doc/lua_api.txt#L3581-L3590)
--- @param area_string string --- @param area_string string
--- @param relative_to Position --- @param relative_to? Position
--- @return Position, Position --- @return Position, Position
function minetest.string_to_area(area_string, relative_to) end function minetest.string_to_area(area_string, relative_to) end
--- returns a string --- returns a string
--- * escapes the characters "[", "]", "\", "," and ";", which can not be used --- * escapes the characters "[", "]", "\", "," and ";", which can not be used
--- in formspecs. --- in formspecs.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3262-L3264) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3262-L3264)
--- @param string string
--- @return string
function minetest.formspec_escape(string) end function minetest.formspec_escape(string) end
--- * returns true if passed 'y', 'yes', 'true' or a number that isn't zero. --- * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3265-L3266) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3265-L3266)
--- --- @param arg any
--- @return boolean --- @return boolean
function minetest.is_yes(arg) end function minetest.is_yes(arg) end
--- * returns true when the passed number represents NaN. --- * returns true when the passed number represents NaN.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3267-L3268) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3267-L3268)
--- --- @param arg any
--- @return boolean --- @return boolean
function minetest.is_nan(arg) end function minetest.is_nan(arg) end
--- * returns time with microsecond precision. May not return wall time. --- * returns time with microsecond precision. May not return wall time.
@@ -196,33 +212,41 @@ function minetest.get_us_time() end
--- * returns the exact position on the surface of a pointed node --- * returns the exact position on the surface of a pointed node
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3291-L3293) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3291-L3293)
--- @param placer Player|ObjectRef
--- @param pointed_thing pointed_thing
--- @return Position
function minetest.pointed_thing_to_face_pos(placer, pointed_thing) end function minetest.pointed_thing_to_face_pos(placer, pointed_thing) end
--- Simulates a tool
--- that digs a node. --- Simulates a tool that digs a node.
--- Returns a table with the following fields: --- Returns a table with the following fields:
--- * `diggable`: `true` if node can be dug, `false` otherwise. --- * `diggable`: `true` if node can be dug, `false` otherwise.
--- * `time`: Time it would take to dig the node. --- * `time`: Time it would take to dig the node.
--- * `wear`: How much wear would be added to the tool. --- * `wear`: How much wear would be added to the tool.
--- `time` and `wear` are meaningless if node's not diggable --- `time` and `wear` are meaningless if node's not diggable
--- Parameters:
--- * `groups`: Table of the node groups of the node that would be dug
--- * `tool_capabilities`: Tool capabilities table of the tool
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3294-L3303) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3294-L3303)
---
--- @param groups table Table of the node groups of the node that would be dug
--- @param tool_capabilities table Tool capabilities table of the tool
--- @return {diggable: boolean, time: number, wear: number}
function minetest.get_dig_params(groups, tool_capabilities) end function minetest.get_dig_params(groups, tool_capabilities) end
--- Simulates an item that punches an object. --- Simulates an item that punches an object.
--- Returns a table with the following fields: --- Returns a table with the following fields:
--- * `hp`: How much damage the punch would cause. --- * `hp`: How much damage the punch would cause.
--- * `wear`: How much wear would be added to the tool. --- * `wear`: How much wear would be added to the tool.
--- Parameters:
--- * `groups`: Damage groups of the object
--- * `tool_capabilities`: Tool capabilities table of the item
--- * `time_from_last_punch`: [Optional] time in seconds since last punch action
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3304-L3312) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3304-L3312)
---
--- @param groups table Damage groups of the object
--- @param tool_capabilities table Tool capabilities table of the item
--- @param time_from_last_punch? number [Optional] time in seconds since last punch action
--- @return {hp: number, wear: number}
function minetest.get_hit_params(groups, tool_capabilities , time_from_last_punch) end function minetest.get_hit_params(groups, tool_capabilities , time_from_last_punch) end
-- Translations^
-- Translations
--- is a simple wrapper around --- is a simple wrapper around
--- `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is --- `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
@@ -268,6 +292,10 @@ function minetest.get_translator(text_domain) end
--- this will be displayed as "Laine Rouge" on clients with a French locale. --- this will be displayed as "Laine Rouge" on clients with a French locale.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3340-L3365) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L3340-L3365)
---
--- @param textdomain string
--- @param str string
--- @return string
function minetest.translate(textdomain, str, ...) end function minetest.translate(textdomain, str, ...) end
@@ -277,17 +305,26 @@ function minetest.translate(textdomain, str, ...) end
--- * Equivalent to `minetest.log(table.concat({...}, "\t"))` --- * Equivalent to `minetest.log(table.concat({...}, "\t"))`
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4458-L4459) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4458-L4459)
--- @param ... any
function minetest.debug(...) end function minetest.debug(...) end
--- * `level` [Optional] is one of `"none"`, `"error"`, `"warning"`, `"action"`,
--- `"info"`, or `"verbose"`. Default is `"none"`. --- @alias LogLevel
--- --- | "none"
--- | "error"
--- | "warning"
--- | "action"
--- | "info"
--- | "verbose"
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4460-L4462) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4460-L4462)
--- ---
--- @overload fun(text:string) --- @overload fun(text:string)
--- @param level string --- @param level? LogLevel # [Optional] is one of `"none"`, `"error"`, `"warning"`, `"action"`, `"info"`, or `"verbose"`. Default is `"none"`.
--- @param text string --- @param text string
function minetest.log(level, text) end function minetest.log(level, text) end
-- Registration functions: -- Registration functions:
-- Environment: -- Environment:
@@ -296,8 +333,8 @@ function minetest.log(level, text) end
--- @param node_definition NodeDefinition table with node definition properties. --- @param node_definition NodeDefinition table with node definition properties.
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4471-L4471) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4471-L4471)
function minetest.register_node(name, node_definition) end function minetest.register_node(name, node_definition) end
--- @param item_definition ItemDefinition
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4472-L4472) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4472-L4472)
--- @param item_definition ItemDefinition
function minetest.register_craftitem(name, item_definition) end function minetest.register_craftitem(name, item_definition) end
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4473-L4473) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4473-L4473)
--- @param name string --- @param name string
@@ -410,9 +447,9 @@ function minetest.register_craft(recipe) end
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4533-L4542) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4533-L4542)
function minetest.clear_craft(recipe) end function minetest.clear_craft(recipe) end
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4543-L4543)
--- @param cmd string --- @param cmd string
--- @param chatcommand_definition ChatCommandDefinition --- @param chatcommand_definition ChatCommandDefinition
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4543-L4543)
function minetest.register_chatcommand(cmd, chatcommand_definition) end function minetest.register_chatcommand(cmd, chatcommand_definition) end
--- * Overrides fields of a chatcommand registered with `register_chatcommand`. --- * Overrides fields of a chatcommand registered with `register_chatcommand`.
--- ---
@@ -882,6 +919,7 @@ function minetest.set_node(pos, node) end
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4841-L4845) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4841-L4845)
function minetest.add_node(pos, node) end function minetest.add_node(pos, node) end
--- * Set node on all positions set in the first argument. --- * Set node on all positions set in the first argument.
--- * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})` --- * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
--- * For node specification or position syntax see `minetest.set_node` call --- * For node specification or position syntax see `minetest.set_node` call
@@ -893,15 +931,25 @@ function minetest.add_node(pos, node) end
--- times faster. --- times faster.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4846-L4855) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4846-L4855)
--- @param positions table {pos1, pos2, pos3, ...} ---
--- @param positions Position[] {pos1, pos2, pos3, ...}
--- @param node NodeTable
function minetest.bulk_set_node(positions, node) end function minetest.bulk_set_node(positions, node) end
--- * Set node at position, but don't remove metadata
--- Swap node at position with another.
--- * This keeps the metadata intact and will not run con-/destructor callbacks.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4856-L4857) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4856-L4857)
---
--- @param pos Position
--- @param node NodeTable
function minetest.swap_node(pos, node) end function minetest.swap_node(pos, node) end
--- * By default it does the same as `minetest.set_node(pos, {name="air"})`
--- Equivalent to core.set_node(pos, {name="air"}), but a bit faster.
--- (Any existing metadata is deleted.)
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4858-L4859) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4858-L4859)
--- @param pos Position
function minetest.remove_node(pos) end function minetest.remove_node(pos) end
--- * Returns the node at the given position as table in the format --- * Returns the node at the given position as table in the format
--- `{name="node_name", param1=0, param2=0}`, --- `{name="node_name", param1=0, param2=0}`,
@@ -914,16 +962,19 @@ function minetest.get_node(pos) end
--- * Same as `get_node` but returns `nil` for unloaded areas. --- * Same as `get_node` but returns `nil` for unloaded areas.
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4864-L4865) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4864-L4865)
--- @param pos Position
--- @return NodeTable|nil
function minetest.get_node_or_nil(pos) end function minetest.get_node_or_nil(pos) end
--- * Gets the light value at the given position. Note that the light value --- * Gets the light value at the given position. Note that the light value
--- "inside" the node at the given position is returned, so you usually want --- "inside" the node at the given position is returned, so you usually want
--- to get the light value of a neighbor. --- to get the light value of a neighbor.
--- * `pos`: The position where to measure the light.
--- * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
--- * Returns a number between `0` and `15` or `nil` --- * Returns a number between `0` and `15` or `nil`
--- * `nil` is returned e.g. when the map isn't loaded at `pos` --- * `nil` is returned e.g. when the map isn't loaded at `pos`
--- ---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4866-L4873) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4866-L4873)
--- @param pos Position The position where to measure the light.
--- @param timeofday number|nil `nil` for current time, `0` for night, `0.5` for day
--- @return number|nil
function minetest.get_node_light(pos, timeofday) end function minetest.get_node_light(pos, timeofday) end
--- * Figures out the sunlight (or moonlight) value at pos at the given time of --- * Figures out the sunlight (or moonlight) value at pos at the given time of
--- day. --- day.
@@ -2016,9 +2067,9 @@ function minetest.read_schematic(schematic, options) end
--- * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN --- * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
--- A LOCAL VARIABLE!** --- A LOCAL VARIABLE!**
--- ---
--- @return HTTPApiTable
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5606-L5616) --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5606-L5616)
---
--- @return HTTPApiTable
function minetest.request_http_api() end function minetest.request_http_api() end
-- Storage API: -- Storage API:
@@ -2439,14 +2490,6 @@ minetest.registered_privileges = {}
-- Built-in libraries and extensions -- Built-in libraries and extensions
-- --
--- @generic T : table
--- @param value T
--- @return T
function table.copy(value) end
--- @param list table
--- @param value any
function table.indexof(list, value) end
--- @param obj any --- @param obj any
--- @param dumped? table --- @param dumped? table
--- @return string --- @return string