Skip to content

Commit

Permalink
Wooden blocks: Refactoring lottplants: add planks API. Closes #1236
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Feb 25, 2024
1 parent 0a5c152 commit cb651b3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mods/lord/Blocks/lottplants/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@ default.register_leafdecay({
radius = 2,
})


dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/planks.lua')
--- @type lottplants.Planks_API
planks = dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/planks.lua')

--Lorien grass

Expand Down
14 changes: 13 additions & 1 deletion mods/lord/Blocks/lottplants/planks.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local S = minetest.get_translator("lottplants")

local planks = { nodes = {} }
local planks = {
--- @type table<string,NodeDefinition>|NodeDefinition[]
nodes = {}
}

--- @param node_name string technical node name ("<mod>:<node>").
local function add_existing(node_name)
Expand Down Expand Up @@ -101,3 +104,12 @@ minetest.register_craft({
recipe = "lottplants:hardwood",
burntime = 28,
})

--- @class lottplants.Planks_API
local Planks_API = {
add_existing = add_existing,
get_nodes = function() return planks.nodes end
}


return Planks_API
2 changes: 1 addition & 1 deletion util/mt-ide-helper/definitions/ItemDefinition.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- @class ItemDefinition
ItemDefinition = {
local ItemDefinition = {
description = "",
-- Can contain new lines. "\n" has to be used as new line character.
-- See also: `get_description` in [`ItemStack`]
Expand Down
2 changes: 1 addition & 1 deletion util/mt-ide-helper/definitions/NodeDefinition.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- @class NodeDefinition: ItemDefinition
NodeDefinition = {
local NodeDefinition = {

drawtype = "normal", -- See "Node drawtypes"

Expand Down
6 changes: 4 additions & 2 deletions util/mt-ide-helper/minetest_types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ function minetest.log(level, text) end

-- Environment:

--- @param name string technical node name ("<mod>:<node>").
--- @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)
function minetest.register_node(name, node_definition) end
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4472-L4472)
Expand Down Expand Up @@ -2286,12 +2288,12 @@ minetest.env = {}
--- * Map of registered items, indexed by name
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5838-L5839)
--- @type table
--- @type table|ItemDefinition[]
minetest.registered_items = {}
--- * Map of registered node definitions, indexed by name
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5840-L5841)
--- @type table
--- @type table<string,NodeDefinition>|NodeDefinition[]
minetest.registered_nodes = {}
--- * Map of registered craft item definitions, indexed by name
---
Expand Down

0 comments on commit cb651b3

Please sign in to comment.