mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-09-12 07:48:38 +02:00
Dont drop items in creative mode when player already has it
This commit is contained in:
parent
e0c61c2f77
commit
d855a3dc00
6
init.lua
6
init.lua
@ -61,6 +61,10 @@ minetest.register_globalstep(function(dtime)
|
||||
end)
|
||||
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
local inv
|
||||
if minetest.setting_getbool("creative_mode") and digger and digger:is_player() then
|
||||
inv = digger:get_inventory()
|
||||
end
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
@ -70,6 +74,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
for i=1,count do
|
||||
local obj = minetest.env:add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
@ -93,6 +98,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
|
Loading…
Reference in New Issue
Block a user