diff --git a/mods/PLAYER/mcl_starting_inventory/README.txt b/mods/ITEMS/mcl_starting_inventory/README.txt similarity index 100% rename from mods/PLAYER/mcl_starting_inventory/README.txt rename to mods/ITEMS/mcl_starting_inventory/README.txt diff --git a/mods/PLAYER/mcl_starting_inventory/init.lua b/mods/ITEMS/mcl_starting_inventory/init.lua similarity index 65% rename from mods/PLAYER/mcl_starting_inventory/init.lua rename to mods/ITEMS/mcl_starting_inventory/init.lua index a72515bc2..c6f1e9bea 100644 --- a/mods/PLAYER/mcl_starting_inventory/init.lua +++ b/mods/ITEMS/mcl_starting_inventory/init.lua @@ -5,6 +5,12 @@ local DEBUG = true +local function mcl_log(message) + if DEBUG then + minetest.log(message) + end +end + local give_inventory = minetest.settings:get("starting_inv_contents", false) local stuff_string @@ -17,7 +23,11 @@ function mcl_starting_inventory.give(player) mcl_log("Giving initial stuff to player " .. player:get_player_name()) local inv = player:get_inventory() for _, stack in ipairs(mcl_starting_inventory.items) do - inv:add_item("main", stack) + if inv:room_for_item("main", stack) then + inv:add_item("main", stack) + else + mcl_log("no room for the item: " .. dump(stack)) + end end end @@ -44,17 +54,22 @@ function mcl_starting_inventory.get_list() return mcl_starting_inventory.items end -local function mcl_log(message) - if DEBUG then - minetest.log(message) - end -end - if give_inventory then stuff_string = "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 32" mcl_starting_inventory.add_from_csv(stuff_string) - mcl_log("okay to give inventory: " .. stuff_string) - if minetest.settings:get_bool("mcl_starting_inventory") then - minetest.register_on_newplayer(mcl_starting_inventory.give) - end + mcl_log("Okay to give inventory:\n" .. dump(mcl_starting_inventory.get_list())) end + +minetest.register_on_newplayer(mcl_starting_inventory.give) + +minetest.register_chatcommand("give_starting_inventory", { + description = "Grant yourself the starting inventory.", + func = function(name, params) + stuff_string = "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 32" + mcl_log("manually giving inventory:\n" .. dump(mcl_starting_inventory.get_list())) + mcl_starting_inventory.add_from_csv(stuff_string) + + minetest.chat_send_player(name, "Granted Starting Inventory.") + return true + end +}) diff --git a/mods/PLAYER/mcl_starting_inventory/license.txt b/mods/ITEMS/mcl_starting_inventory/license.txt similarity index 100% rename from mods/PLAYER/mcl_starting_inventory/license.txt rename to mods/ITEMS/mcl_starting_inventory/license.txt diff --git a/mods/PLAYER/mcl_starting_inventory/mod.conf b/mods/ITEMS/mcl_starting_inventory/mod.conf similarity index 100% rename from mods/PLAYER/mcl_starting_inventory/mod.conf rename to mods/ITEMS/mcl_starting_inventory/mod.conf