mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-08-20 13:14:09 +02:00
Don't override handle_node_drops in creative mode
This commit is contained in:
parent
ac2da1689e
commit
f811009c80
53
init.lua
53
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
|
for _ = 1,count do
|
||||||
or not inv:contains_item("main", ItemStack(name)) then
|
local obj = minetest.add_item(pos, name)
|
||||||
for _ = 1,count do
|
if not obj then
|
||||||
local obj = minetest.add_item(diggerPos, name)
|
error("Couldn't spawn item")
|
||||||
|
|
||||||
if obj then
|
|
||||||
obj:get_luaentity().collect = true
|
|
||||||
local x = math.random(-5, 4)
|
|
||||||
if x >= 0 then
|
|
||||||
x = x+1
|
|
||||||
end
|
|
||||||
local z = math.random(-5, 4)
|
|
||||||
if z >= 0 then
|
|
||||||
z = z+1
|
|
||||||
end
|
|
||||||
|
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local vel = obj:getvelocity()
|
||||||
|
local x = math.random(-5, 4)
|
||||||
|
if x >= 0 then
|
||||||
|
x = x+1
|
||||||
|
end
|
||||||
|
vel.x = x
|
||||||
|
local z = math.random(-5, 4)
|
||||||
|
if z >= 0 then
|
||||||
|
z = z+1
|
||||||
|
end
|
||||||
|
vel.z = z
|
||||||
|
obj:setvelocity(vel)
|
||||||
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