Browse Source

new command: clear player saved inventory

main
Hendrik Langer 3 years ago
parent
commit
f5a5c13a6a
  1. 22
      chatcommands.lua

22
chatcommands.lua

@ -117,3 +117,25 @@ minetest.register_chatcommand("creative_region_rn", {
return true, "Done."
end,
})
minetest.register_chatcommand("creative_region_clearinv", {
params = S("<name> <inventory>"),
description = S("Clear a saved inventory of yourself or another player"),
privs = {server = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local playerName, inventoryName = param:match("^(%S+)%s(.+)$")
if not playerName or not inventoryListName then
return false, "Syntax error"
end
player = minetest.get_player_by_name(playerName)
if not player then
return false, S("Player not found")
end
player:get_inventory():set_list(inventoryListName, {})
minetest.chat_send_player(name, S("Cleared @1's inventory list '@2'", player:get_player_name(), inventoryListName))
return true, S("Done")
end,
})

Loading…
Cancel
Save