diff options
author | Lord89James <neftali_dtctv@hotmail.com> | 2013-03-12 01:29:02 +0100 |
---|---|---|
committer | BlockMen <nmuelll@web.de> | 2014-06-10 18:11:43 +0200 |
commit | 9675d9e9cb1f951a154d2fcd26fea6fb94632c7d (patch) | |
tree | dd17c614c576d19f8dccc11713ccdffe60458096 /builtin | |
parent | c6a9eae3aedb69eea186b39aa1f87ecb31698424 (diff) | |
download | minetest-9675d9e9cb1f951a154d2fcd26fea6fb94632c7d.tar.gz minetest-9675d9e9cb1f951a154d2fcd26fea6fb94632c7d.tar.bz2 minetest-9675d9e9cb1f951a154d2fcd26fea6fb94632c7d.zip |
New feature: drop a item instead a stack while...
sneaking
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/item.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 11a36bdc3..e136d4f4c 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -335,20 +335,26 @@ function core.item_place(itemstack, placer, pointed_thing, param2) end function core.item_drop(itemstack, dropper, pos) - if dropper.get_player_name then + if dropper.is_player then local v = dropper:get_look_dir() - local p = {x=pos.x+v.x, y=pos.y+1.5+v.y, z=pos.z+v.z} - local obj = core.add_item(p, itemstack) + local p = {x=pos.x, y=pos.y+1.2, z=pos.z} + local cs = itemstack:get_count() + if dropper:get_player_control().sneak then + cs = 1 + end + local item = itemstack:take_item(cs) + local obj = core.add_item(p, item) if obj then v.x = v.x*2 - v.y = v.y*2 + 1 + v.y = v.y*2 + 2 v.z = v.z*2 obj:setvelocity(v) end + else core.add_item(pos, itemstack) end - return ItemStack("") + return itemstack end function core.item_eat(hp_change, replace_with_item) @@ -592,4 +598,3 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items on_drop = nil, on_use = nil, } - |