Aux+drop dumps entire inventory
This commit is contained in:
parent
0440a0644e
commit
387a72ccbc
30
mods/nc_player_pickup/dropall.lua
Normal file
30
mods/nc_player_pickup/dropall.lua
Normal 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
|
@ -8,3 +8,4 @@ nodecore.amcoremod()
|
||||
include("api")
|
||||
include("intercept")
|
||||
include("rearrange")
|
||||
include("dropall")
|
||||
|
Loading…
x
Reference in New Issue
Block a user