From 4e3d2b7b740dc023543a93bd25283f3e6dac7f3e Mon Sep 17 00:00:00 2001 From: alek13 Date: Tue, 30 Sep 2025 04:38:37 +0300 Subject: [PATCH] Modern Lua Plugins: `ide-helper` improvements. LG-1978, LG-1980 --- core_namespace.lua | 11 +++++++++++ definitions/ItemDefinition.lua | 9 ++++----- definitions/NodeDefinition.lua | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core_namespace.lua b/core_namespace.lua index abd91f0..2737d12 100644 --- a/core_namespace.lua +++ b/core_namespace.lua @@ -1678,6 +1678,12 @@ function minetest.rollback_revert_actions_by(actor, seconds) end --- * `position`: the location the node was placed to. `nil` if nothing was placed. --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5358-L5364) +--- @param itemstack ItemStack +--- @param placer Player|ObjectRef +--- @param pointed_thing pointed_thing +--- @param param2 number +--- @param prevent_after_place boolean +--- @return ItemStack, vector|nil function minetest.item_place_node(itemstack, placer, pointed_thing, param2, prevent_after_place) end --- * Place item as-is --- * returns the leftover itemstack @@ -1693,6 +1699,11 @@ function minetest.item_place_object(itemstack, placer, pointed_thing) end --- * `position`: the location the node was placed to. `nil` if nothing was placed. --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5369-L5375) +--- @param itemstack ItemStack +--- @param placer Player|ObjectRef|nil +--- @param pointed_thing pointed_thing +--- @param param2 number +--- @return ItemStack, vector|nil function minetest.item_place(itemstack, placer, pointed_thing, param2) end --- * Drop the item --- * returns the leftover itemstack diff --git a/definitions/ItemDefinition.lua b/definitions/ItemDefinition.lua index 118248b..90d0b39 100644 --- a/definitions/ItemDefinition.lua +++ b/definitions/ItemDefinition.lua @@ -173,13 +173,12 @@ local ItemDefinition = { punch_use_air = nil, }, - --- When the 'place' key was pressed with the item in hand - --- and a node was pointed at. - --- Shall place item and return the leftover itemstack - --- or nil to not modify the inventory. + --- When the 'place' key was pressed with the item in hand and a node was pointed at. + --- Shall place item and return the leftover itemstack or nil to not modify the inventory. + --- Second return value: position of placed item/node. --- The placer may be any ObjectRef or nil. --- default: minetest.item_place - --- @type fun(itemstack:ItemStack, placer:Player|ObjectRef|nil, pointed_thing:pointed_thing)? + --- @type (fun(itemstack:ItemStack, placer:Player|ObjectRef|nil, pointed_thing:pointed_thing):ItemStack|nil, Position|vector|nil)? on_place = minetest.item_place, --- Same as on_place but called when not pointing at a node. diff --git a/definitions/NodeDefinition.lua b/definitions/NodeDefinition.lua index 226bf1f..d9de03c 100644 --- a/definitions/NodeDefinition.lua +++ b/definitions/NodeDefinition.lua @@ -574,8 +574,8 @@ local NodeDefinition = { --- 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:Position, node:NodeTable, clicker:Player|ObjectRef|nil, itemstack:ItemStack, pointed_thing:pointed_thing|nil)? - on_rightclick = nil, + --- @type (fun(pos:Position, node:NodeTable, clicker:Player|ObjectRef, itemstack:ItemStack, pointed_thing:pointed_thing|nil):ItemStack|nil)? + on_rightclick = core.node_punch, --- default: minetest.node_dig --- By default checks privileges, wears out item (if tool) and removes node.