Skip to content
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ globals = {

read_globals = {
"core",
math = { fields = { "round" } },
"table.copy",
"table.indexof",
"minetest",
Expand Down
18 changes: 17 additions & 1 deletion nodes/drawers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@

local INT, STRING = wrench.META_TYPE_INT, wrench.META_TYPE_STRING

local function description(pos, meta, node, player)
local item_name = meta:get_string("name")
-- Ignore cabinets with multiple drawers and empty ones.
if item_name == "" then
return wrench.description_with_items(pos, meta, node, player)
end

local item_desc = ItemStack(item_name):get_short_description()
local count = meta:get_int("count")
if 1000 <= count then
count = math.round(count * .001) .. "k"
end
return count .. " " .. item_desc
end

-- Assemble definitions for drawer type 1, 2 and 4
for _, drawer_type in ipairs({1, 2, 4}) do

Expand All @@ -11,7 +26,8 @@ for _, drawer_type in ipairs({1, 2, 4}) do
metas = {
formspec = wrench.META_TYPE_IGNORE,
},
after_place = drawers.spawn_visuals
after_place = drawers.spawn_visuals,
description = description,
}

for i=1, drawer_type do
Expand Down