From 181628e5395f2ce6307c7a4327f7044643c58541 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 00:51:23 -0500 Subject: [PATCH] Starting Inventory fix #2 --- mods/PLAYER/mcl_starting_inventory/init.lua | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mods/PLAYER/mcl_starting_inventory/init.lua b/mods/PLAYER/mcl_starting_inventory/init.lua index dbb469cbd..a72515bc2 100644 --- a/mods/PLAYER/mcl_starting_inventory/init.lua +++ b/mods/PLAYER/mcl_starting_inventory/init.lua @@ -3,20 +3,18 @@ --- --- Copyright notice created for the license to be valid. (MIT 3) +local DEBUG = true + local give_inventory = minetest.settings:get("starting_inv_contents", false) local stuff_string -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" -end mcl_starting_inventory = { items = {} } function mcl_starting_inventory.give(player) - minetest.log("action", - "Giving initial stuff to player " .. player:get_player_name()) + 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) @@ -46,7 +44,17 @@ function mcl_starting_inventory.get_list() return mcl_starting_inventory.items end -mcl_starting_inventory.add_from_csv(stuff_string) -if minetest.settings:get_bool("mcl_starting_inventory") then - minetest.register_on_newplayer(mcl_starting_inventory.give) +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 end