entity_detactor: detect stacks of dropped items

This commit is contained in:
tour
2025-11-12 01:25:48 +01:00
committed by SmallJoker
parent 3b0d06569d
commit 46d1f500bf
2 changed files with 8 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
read_globals = {
-- Defined by Minetest
"minetest", "vector", "PseudoRandom", "VoxelArea", "table",
"minetest", "vector", "PseudoRandom", "VoxelArea", "table", "ItemStack",
-- Mods
"digiline", "default", "creative",

View File

@@ -46,9 +46,14 @@ local object_detector_scan = function (pos)
return true
end
local isname = luaentity.name
-- If the item is present as dropped item entity:
local bitemname = (isname == "__builtin:item" and ItemStack(luaentity.itemstring):get_name())
for _, name in ipairs(scan_names) do
if isname == name or (isname == "__builtin:item" and luaentity.itemstring == name) then
return true
if name == isname then
return true -- object name matches
end
if name == bitemname then
return true -- item of the item entity matches
end
end
end