0
0
Fork 0

Dropping drops entire item stack again

This commit is contained in:
Wuzzy 2017-02-18 21:59:24 +01:00
parent 29b418f719
commit 635b60c17f
1 changed files with 22 additions and 18 deletions

View File

@ -9,6 +9,8 @@ item_drop_settings.collect_by_default = true --make item entities automatical
--versus setting it in the item drop code, setting true might interfere with --versus setting it in the item drop code, setting true might interfere with
--mods that use item entities (like pipeworks) --mods that use item entities (like pipeworks)
item_drop_settings.random_item_velocity = true --this sets random item velocity if velocity is 0 item_drop_settings.random_item_velocity = true --this sets random item velocity if velocity is 0
item_drop_settings.drop_single_item = false --if true, the drop control drops 1 item instead of the entire stack, and sneak+drop drops the stack
-- drop_single_item is disabled by default because it is annoying to throw away items from the intentory screen
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
@ -145,24 +147,26 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
end end
--throw single items by default if item_drop_settings.drop_single_item then
function minetest.item_drop(itemstack, dropper, pos) -- Drop single items by default
if dropper and dropper:is_player() then function minetest.item_drop(itemstack, dropper, pos)
local v = dropper:get_look_dir() if dropper and dropper:is_player() then
local p = {x=pos.x, y=pos.y+1.2, z=pos.z} local v = dropper:get_look_dir()
local cs = 1 local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
if dropper:get_player_control().sneak then local cs = 1
cs = itemstack:get_count() if dropper:get_player_control().sneak then
end cs = itemstack:get_count()
local item = itemstack:take_item(cs) end
local obj = core.add_item(p, item) local item = itemstack:take_item(cs)
if obj then local obj = core.add_item(p, item)
v.x = v.x*4 if obj then
v.y = v.y*4 + 2 v.x = v.x*4
v.z = v.z*4 v.y = v.y*4 + 2
obj:setvelocity(v) v.z = v.z*4
obj:get_luaentity().collect = true obj:setvelocity(v)
return itemstack obj:get_luaentity().collect = true
return itemstack
end
end end
end end
end end