Aux+drop dumps entire inventory

This commit is contained in:
Aaron Suen 2020-09-03 20:22:09 -04:00
parent 0440a0644e
commit 387a72ccbc
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,30 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest
= minetest
-- LUALOCALS > ---------------------------------------------------------
local droppingall = {}
local function dropall(pname, pos)
local player = minetest.get_player_by_name(pname)
if not player then return end
if droppingall[pname] then return end
droppingall[pname] = true
local inv = player:get_inventory()
for i = 1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
stack = minetest.item_drop(stack, player, pos)
inv:set_stack("main", i, stack)
end
end
droppingall[pname] = nil
end
local olddrop = minetest.item_drop
function minetest.item_drop(item, player, ...)
if player:get_player_control().aux1 then
local pname = player:get_player_name()
minetest.after(0, dropall, pname, player:get_pos())
end
return olddrop(item, player, ...)
end

View File

@ -8,3 +8,4 @@ nodecore.amcoremod()
include("api")
include("intercept")
include("rearrange")
include("dropall")