nodecore-cd2025/mods/nc_api/item_virtual.lua
Aaron Suen 89020e8340 Major rebuild of item_entity.
This created a ton of dependency inversions, which
necessitated moving a number of API functions up into
higher layers, and restructuring dependency lists for
a number of mods.

BOLO: non-deterministic load errors due to missed
dependencies.
2020-01-05 11:42:22 -05:00

20 lines
635 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local ItemStack, minetest, nodecore
= ItemStack, minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
local function isvirtual(item)
return (ItemStack(item):get_definition() or {}).virtual_item
end
nodecore.item_is_virtual = isvirtual
local function guard(func)
return function(pos, item, ...)
if not item then return func(pos, item, ...) end
if isvirtual(item) then return end
return func(pos, item, ...)
end
end
minetest.spawn_item = guard(minetest.spawn_item)
minetest.add_item = guard(minetest.add_item)