summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-01-09 18:22:37 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2016-01-09 18:22:37 +0000
commit82344b7a0d3908036497577e82cc36e066d3d52d (patch)
treeff6f31a6d57924be48da6478fd5317ffed50ed0a
parent4e51158cdcd41ccbce4affa3a186b6ace59b4d7a (diff)
violation drop after delay to stop stack doubling
-rw-r--r--init.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/init.lua b/init.lua
index e3108be..3c641fe 100644
--- a/init.lua
+++ b/init.lua
@@ -228,16 +228,18 @@ function minetest.is_protected(pos, digger)
if holding:to_string() ~= "" then
+ -- take stack
local sta = holding:take_item(holding:get_count())
- local obj = minetest.add_item(player:getpos(), sta)
+ player:set_wielded_item(holding)
- if obj then
- obj:setvelocity({x = 0, y = 5, z = 0})
+ -- incase of lag, reset stack
+ minetest.after(0.1, function()
player:set_wielded_item(holding)
- minetest.after(0.2, function()
- player:set_wielded_item(holding)
- end)
- end
+
+ -- drop stack
+ local obj = minetest.add_item(player:getpos(), sta)
+ obj:setvelocity({x = 0, y = 5, z = 0})
+ end)
end