mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-12-23 06:12:30 +01:00
Don't override handle_node_drops in creative mode
This commit is contained in:
parent
ac2da1689e
commit
f811009c80
35
init.lua
35
init.lua
@ -203,21 +203,9 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
|
|||||||
minetest.after(3.0, pickup_step)
|
minetest.after(3.0, pickup_step)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.settings:get_bool("item_drop.enable_item_drop") ~= false then
|
if minetest.settings:get_bool("item_drop.enable_item_drop") ~= false
|
||||||
local creative_enabled = minetest.settings:get_bool("creative_mode")
|
and not minetest.settings:get_bool("creative_mode") then
|
||||||
|
function minetest.handle_node_drops(pos, drops)
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
|
||||||
|
|
||||||
local inv
|
|
||||||
local diggerPos = pos
|
|
||||||
|
|
||||||
if creative_enabled
|
|
||||||
and digger
|
|
||||||
and digger:is_player() then
|
|
||||||
inv = digger:get_inventory()
|
|
||||||
diggerPos = digger:getpos()
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1,#drops do
|
for i = 1,#drops do
|
||||||
local item = drops[i]
|
local item = drops[i]
|
||||||
local count, name
|
local count, name
|
||||||
@ -229,25 +217,24 @@ if minetest.settings:get_bool("item_drop.enable_item_drop") ~= false then
|
|||||||
name = item:get_name()
|
name = item:get_name()
|
||||||
end
|
end
|
||||||
|
|
||||||
if not inv
|
|
||||||
or not inv:contains_item("main", ItemStack(name)) then
|
|
||||||
for _ = 1,count do
|
for _ = 1,count do
|
||||||
local obj = minetest.add_item(diggerPos, name)
|
local obj = minetest.add_item(pos, name)
|
||||||
|
if not obj then
|
||||||
|
error("Couldn't spawn item")
|
||||||
|
end
|
||||||
|
|
||||||
if obj then
|
local vel = obj:getvelocity()
|
||||||
obj:get_luaentity().collect = true
|
|
||||||
local x = math.random(-5, 4)
|
local x = math.random(-5, 4)
|
||||||
if x >= 0 then
|
if x >= 0 then
|
||||||
x = x+1
|
x = x+1
|
||||||
end
|
end
|
||||||
|
vel.x = x
|
||||||
local z = math.random(-5, 4)
|
local z = math.random(-5, 4)
|
||||||
if z >= 0 then
|
if z >= 0 then
|
||||||
z = z+1
|
z = z+1
|
||||||
end
|
end
|
||||||
|
vel.z = z
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
obj:setvelocity(vel)
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#Pick up items automatically
|
#Pick up items automatically
|
||||||
item_drop.enable_item_pickup (Enable item pickups) bool true
|
item_drop.enable_item_pickup (Enable item pickups) bool true
|
||||||
|
|
||||||
#Drop items in-world on dig
|
#Drop items in-world on dig, does nothing in creative mode
|
||||||
item_drop.enable_item_drop (Enable item drops) bool true
|
item_drop.enable_item_drop (Enable item drops) bool true
|
||||||
|
|
||||||
#Use a key to pick up items
|
#Use a key to pick up items
|
||||||
|
Loading…
Reference in New Issue
Block a user