From 5424ca8c2b5af9c1bafd00ab5178f6b95a288ed9 Mon Sep 17 00:00:00 2001 From: Michieal Date: Sun, 15 Jan 2023 20:39:51 -0500 Subject: [PATCH 1/9] Created Starting Chest that is given to players. Based on the "give_initial_stuff" mod. --- mods/PLAYER/mcl_starting_chest/README.txt | 11 +++++ mods/PLAYER/mcl_starting_chest/init.lua | 49 ++++++++++++++++++++++ mods/PLAYER/mcl_starting_chest/license.txt | 25 +++++++++++ mods/PLAYER/mcl_starting_chest/mod.conf | 3 ++ settingtypes.txt | 3 ++ 5 files changed, 91 insertions(+) create mode 100644 mods/PLAYER/mcl_starting_chest/README.txt create mode 100644 mods/PLAYER/mcl_starting_chest/init.lua create mode 100644 mods/PLAYER/mcl_starting_chest/license.txt create mode 100644 mods/PLAYER/mcl_starting_chest/mod.conf diff --git a/mods/PLAYER/mcl_starting_chest/README.txt b/mods/PLAYER/mcl_starting_chest/README.txt new file mode 100644 index 000000000..da63a662b --- /dev/null +++ b/mods/PLAYER/mcl_starting_chest/README.txt @@ -0,0 +1,11 @@ +Adapted for Mineclone 2 by Michieal. + +Based on: +Minetest Game mod: give_initial_stuff +===================================== +See license.txt for license information. + +Authors of source code +---------------------- +Perttu Ahola (celeron55) (MIT) +Various Minetest developers and contributors (MIT) diff --git a/mods/PLAYER/mcl_starting_chest/init.lua b/mods/PLAYER/mcl_starting_chest/init.lua new file mode 100644 index 000000000..5ee21e22b --- /dev/null +++ b/mods/PLAYER/mcl_starting_chest/init.lua @@ -0,0 +1,49 @@ +--- Copyright 2023, Michieal. (Modifications for the mod to be usable in Mineclone 2.) +--- Based on mtg mod, give_initial_stuff. "Written by C55 and various minetest developers." +--- +--- Copyright notice created for the license to be valid. (MIT 3) + +local stuff_string = minetest.settings:get("starter_chest_contents") or + "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron," .. + "mcl_torches:torch 32,mcl_core:cobble 64" + +mcl_starting_chest = { + items = {} +} + +function mcl_starting_chest.give(player) + minetest.log("action", + "Giving initial stuff to player " .. player:get_player_name()) + local inv = player:get_inventory() + for _, stack in ipairs(mcl_starting_chest.items) do + inv:add_item("main", stack) + end +end + +function mcl_starting_chest.add(stack) + mcl_starting_chest.items[#mcl_starting_chest.items + 1] = ItemStack(stack) +end + +function mcl_starting_chest.clear() + mcl_starting_chest.items = {} +end + +function mcl_starting_chest.add_from_csv(str) + local items = str:split(",") + for _, itemname in ipairs(items) do + mcl_starting_chest.add(itemname) + end +end + +function mcl_starting_chest.set_list(list) + mcl_starting_chest.items = list +end + +function mcl_starting_chest.get_list() + return mcl_starting_chest.items +end + +mcl_starting_chest.add_from_csv(stuff_string) +if minetest.settings:get_bool("mcl_starting_chest") then + minetest.register_on_newplayer(mcl_starting_chest.give) +end diff --git a/mods/PLAYER/mcl_starting_chest/license.txt b/mods/PLAYER/mcl_starting_chest/license.txt new file mode 100644 index 000000000..8134c920e --- /dev/null +++ b/mods/PLAYER/mcl_starting_chest/license.txt @@ -0,0 +1,25 @@ +License of source code +---------------------- + +The MIT License (MIT) +Copyright (C) 2012-2016 Perttu Ahola (celeron55) +Copyright (C) 2012-2016 Various Minetest developers and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +For more details: +https://opensource.org/licenses/MIT diff --git a/mods/PLAYER/mcl_starting_chest/mod.conf b/mods/PLAYER/mcl_starting_chest/mod.conf new file mode 100644 index 000000000..2232e117b --- /dev/null +++ b/mods/PLAYER/mcl_starting_chest/mod.conf @@ -0,0 +1,3 @@ +name = mcl_starting_chest +description = Mineclone 2 mod, Starting Chest. (Gives starter chest to players.) +depends = mcl_core, mcl_chests diff --git a/settingtypes.txt b/settingtypes.txt index d68b5793d..7854aa19a 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -231,6 +231,9 @@ mcl_extended_pet_control (Extended pet control) bool true # Enable hamburgers for villagers to follow mcl_enable_hamburger (Enable Hamburger) bool true +# Starting chest contents (given directly to the new player) type: string +starter_chest_contents (player starter pack) string "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 64" + [Debugging] # If enabled, this will show the itemstring of an item in the description. mcl_item_id_debug (Item ID Debug) bool false From 45b4b4a458871c206455d183300fe23da67a0713 Mon Sep 17 00:00:00 2001 From: Michieal Date: Sun, 15 Jan 2023 21:21:26 -0500 Subject: [PATCH 2/9] renamed to mcl_starting_inventory as that is what it is. --- mods/PLAYER/mcl_starting_chest/init.lua | 49 ------------------- .../README.txt | 2 +- mods/PLAYER/mcl_starting_inventory/init.lua | 49 +++++++++++++++++++ .../license.txt | 0 .../mod.conf | 2 +- 5 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 mods/PLAYER/mcl_starting_chest/init.lua rename mods/PLAYER/{mcl_starting_chest => mcl_starting_inventory}/README.txt (82%) create mode 100644 mods/PLAYER/mcl_starting_inventory/init.lua rename mods/PLAYER/{mcl_starting_chest => mcl_starting_inventory}/license.txt (100%) rename mods/PLAYER/{mcl_starting_chest => mcl_starting_inventory}/mod.conf (78%) diff --git a/mods/PLAYER/mcl_starting_chest/init.lua b/mods/PLAYER/mcl_starting_chest/init.lua deleted file mode 100644 index 5ee21e22b..000000000 --- a/mods/PLAYER/mcl_starting_chest/init.lua +++ /dev/null @@ -1,49 +0,0 @@ ---- Copyright 2023, Michieal. (Modifications for the mod to be usable in Mineclone 2.) ---- Based on mtg mod, give_initial_stuff. "Written by C55 and various minetest developers." ---- ---- Copyright notice created for the license to be valid. (MIT 3) - -local stuff_string = minetest.settings:get("starter_chest_contents") or - "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron," .. - "mcl_torches:torch 32,mcl_core:cobble 64" - -mcl_starting_chest = { - items = {} -} - -function mcl_starting_chest.give(player) - minetest.log("action", - "Giving initial stuff to player " .. player:get_player_name()) - local inv = player:get_inventory() - for _, stack in ipairs(mcl_starting_chest.items) do - inv:add_item("main", stack) - end -end - -function mcl_starting_chest.add(stack) - mcl_starting_chest.items[#mcl_starting_chest.items + 1] = ItemStack(stack) -end - -function mcl_starting_chest.clear() - mcl_starting_chest.items = {} -end - -function mcl_starting_chest.add_from_csv(str) - local items = str:split(",") - for _, itemname in ipairs(items) do - mcl_starting_chest.add(itemname) - end -end - -function mcl_starting_chest.set_list(list) - mcl_starting_chest.items = list -end - -function mcl_starting_chest.get_list() - return mcl_starting_chest.items -end - -mcl_starting_chest.add_from_csv(stuff_string) -if minetest.settings:get_bool("mcl_starting_chest") then - minetest.register_on_newplayer(mcl_starting_chest.give) -end diff --git a/mods/PLAYER/mcl_starting_chest/README.txt b/mods/PLAYER/mcl_starting_inventory/README.txt similarity index 82% rename from mods/PLAYER/mcl_starting_chest/README.txt rename to mods/PLAYER/mcl_starting_inventory/README.txt index da63a662b..126504b04 100644 --- a/mods/PLAYER/mcl_starting_chest/README.txt +++ b/mods/PLAYER/mcl_starting_inventory/README.txt @@ -1,4 +1,4 @@ -Adapted for Mineclone 2 by Michieal. +Mcl_starting_inventory, adapted for Mineclone 2 by Michieal. Based on: Minetest Game mod: give_initial_stuff diff --git a/mods/PLAYER/mcl_starting_inventory/init.lua b/mods/PLAYER/mcl_starting_inventory/init.lua new file mode 100644 index 000000000..836cb17a6 --- /dev/null +++ b/mods/PLAYER/mcl_starting_inventory/init.lua @@ -0,0 +1,49 @@ +--- Copyright 2023, Michieal. (Modifications for the mod to be usable in Mineclone 2.) +--- Based on mtg mod, give_initial_stuff. "Written by C55 and various minetest developers." +--- +--- Copyright notice created for the license to be valid. (MIT 3) + +local stuff_string = minetest.settings:get("starter_chest_contents") or + "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron," .. + "mcl_torches:torch 32,mcl_core:cobble 64" + +mcl_starting_inventory = { + items = {} +} + +function mcl_starting_inventory.give(player) + minetest.log("action", + "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) + end +end + +function mcl_starting_inventory.add(stack) + mcl_starting_inventory.items[#mcl_starting_inventory.items + 1] = ItemStack(stack) +end + +function mcl_starting_inventory.clear() + mcl_starting_inventory.items = {} +end + +function mcl_starting_inventory.add_from_csv(str) + local items = str:split(",") + for _, itemname in ipairs(items) do + mcl_starting_inventory.add(itemname) + end +end + +function mcl_starting_inventory.set_list(list) + mcl_starting_inventory.items = list +end + +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) +end diff --git a/mods/PLAYER/mcl_starting_chest/license.txt b/mods/PLAYER/mcl_starting_inventory/license.txt similarity index 100% rename from mods/PLAYER/mcl_starting_chest/license.txt rename to mods/PLAYER/mcl_starting_inventory/license.txt diff --git a/mods/PLAYER/mcl_starting_chest/mod.conf b/mods/PLAYER/mcl_starting_inventory/mod.conf similarity index 78% rename from mods/PLAYER/mcl_starting_chest/mod.conf rename to mods/PLAYER/mcl_starting_inventory/mod.conf index 2232e117b..d79c6e0af 100644 --- a/mods/PLAYER/mcl_starting_chest/mod.conf +++ b/mods/PLAYER/mcl_starting_inventory/mod.conf @@ -1,3 +1,3 @@ -name = mcl_starting_chest +name = mcl_starting_inventory description = Mineclone 2 mod, Starting Chest. (Gives starter chest to players.) depends = mcl_core, mcl_chests From 26f3275b7c944847494a6e9929861da62826a164 Mon Sep 17 00:00:00 2001 From: Michieal Date: Sun, 15 Jan 2023 21:23:49 -0500 Subject: [PATCH 3/9] renamed to mcl_starting_inventory... continued. Fixed the setting in settingtypes.txt --- mods/PLAYER/mcl_starting_inventory/init.lua | 2 +- settingtypes.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_starting_inventory/init.lua b/mods/PLAYER/mcl_starting_inventory/init.lua index 836cb17a6..fa823810d 100644 --- a/mods/PLAYER/mcl_starting_inventory/init.lua +++ b/mods/PLAYER/mcl_starting_inventory/init.lua @@ -3,7 +3,7 @@ --- --- Copyright notice created for the license to be valid. (MIT 3) -local stuff_string = minetest.settings:get("starter_chest_contents") or +local stuff_string = minetest.settings:get("starting_inv_contents") or "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron," .. "mcl_torches:torch 32,mcl_core:cobble 64" diff --git a/settingtypes.txt b/settingtypes.txt index 7854aa19a..c183da7ed 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -231,8 +231,8 @@ mcl_extended_pet_control (Extended pet control) bool true # Enable hamburgers for villagers to follow mcl_enable_hamburger (Enable Hamburger) bool true -# Starting chest contents (given directly to the new player) type: string -starter_chest_contents (player starter pack) string "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 64" +# Starting inventory contents (given directly to the new player) type: string +starting_inv_contents (player starter pack) string "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 64" [Debugging] # If enabled, this will show the itemstring of an item in the description. From c57a757510e3b540178f74707b8b80028ecc0a46 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 00:21:15 -0500 Subject: [PATCH 4/9] Starting Inventory fix #1/ --- mods/PLAYER/mcl_starting_inventory/init.lua | 9 ++++++--- mods/PLAYER/mcl_starting_inventory/mod.conf | 4 ++-- settingtypes.txt | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mods/PLAYER/mcl_starting_inventory/init.lua b/mods/PLAYER/mcl_starting_inventory/init.lua index fa823810d..dbb469cbd 100644 --- a/mods/PLAYER/mcl_starting_inventory/init.lua +++ b/mods/PLAYER/mcl_starting_inventory/init.lua @@ -3,9 +3,12 @@ --- --- Copyright notice created for the license to be valid. (MIT 3) -local stuff_string = minetest.settings:get("starting_inv_contents") or - "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron," .. - "mcl_torches:torch 32,mcl_core:cobble 64" +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 = {} diff --git a/mods/PLAYER/mcl_starting_inventory/mod.conf b/mods/PLAYER/mcl_starting_inventory/mod.conf index d79c6e0af..de938b831 100644 --- a/mods/PLAYER/mcl_starting_inventory/mod.conf +++ b/mods/PLAYER/mcl_starting_inventory/mod.conf @@ -1,3 +1,3 @@ name = mcl_starting_inventory -description = Mineclone 2 mod, Starting Chest. (Gives starter chest to players.) -depends = mcl_core, mcl_chests +description = Mineclone 2 mod, Starting Inventory +depends = mcl_core, mcl_tools, diff --git a/settingtypes.txt b/settingtypes.txt index c183da7ed..fe93771c6 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -231,8 +231,8 @@ mcl_extended_pet_control (Extended pet control) bool true # Enable hamburgers for villagers to follow mcl_enable_hamburger (Enable Hamburger) bool true -# Starting inventory contents (given directly to the new player) type: string -starting_inv_contents (player starter pack) string "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 64" +# Starting Inventory contents (given directly to the new player) type: string +starting_inv_contents (Player Starter Pack) bool false [Debugging] # If enabled, this will show the itemstring of an item in the description. From 181628e5395f2ce6307c7a4327f7044643c58541 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 00:51:23 -0500 Subject: [PATCH 5/9] 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 From d68667beb977f1a2b069e759a4f98769d5ef74fc Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 01:53:35 -0500 Subject: [PATCH 6/9] Starting Inventory fix #2. add in chat command, /give_starting_inventory. add in debug code. --- .../mcl_starting_inventory/README.txt | 0 .../mcl_starting_inventory/init.lua | 37 +++++++++++++------ .../mcl_starting_inventory/license.txt | 0 .../mcl_starting_inventory/mod.conf | 0 4 files changed, 26 insertions(+), 11 deletions(-) rename mods/{PLAYER => ITEMS}/mcl_starting_inventory/README.txt (100%) rename mods/{PLAYER => ITEMS}/mcl_starting_inventory/init.lua (65%) rename mods/{PLAYER => ITEMS}/mcl_starting_inventory/license.txt (100%) rename mods/{PLAYER => ITEMS}/mcl_starting_inventory/mod.conf (100%) 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 From 88493091b60d475f6234a48368d17371b27bfc85 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 01:58:27 -0500 Subject: [PATCH 7/9] Starting Inventory fix #3. turn off debugging in code. Ready for testing. --- mods/ITEMS/mcl_starting_inventory/init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_starting_inventory/init.lua b/mods/ITEMS/mcl_starting_inventory/init.lua index c6f1e9bea..5644e3d06 100644 --- a/mods/ITEMS/mcl_starting_inventory/init.lua +++ b/mods/ITEMS/mcl_starting_inventory/init.lua @@ -3,7 +3,7 @@ --- --- Copyright notice created for the license to be valid. (MIT 3) -local DEBUG = true +local DEBUG = false local function mcl_log(message) if DEBUG then @@ -66,9 +66,8 @@ 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_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 From d48b3dcaeec7523890029d88a21641bc37bebeb0 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 16 Jan 2023 02:12:39 -0500 Subject: [PATCH 8/9] Starting Inventory fix #4 Optimized and remove chatcommand. --- mods/ITEMS/mcl_starting_inventory/init.lua | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_starting_inventory/init.lua b/mods/ITEMS/mcl_starting_inventory/init.lua index 5644e3d06..dfd2ba6db 100644 --- a/mods/ITEMS/mcl_starting_inventory/init.lua +++ b/mods/ITEMS/mcl_starting_inventory/init.lua @@ -13,7 +13,7 @@ end local give_inventory = minetest.settings:get("starting_inv_contents", false) -local stuff_string +local 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 = { items = {} @@ -55,20 +55,8 @@ function mcl_starting_inventory.get_list() 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:\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 -}) From 29597af73884e89ad5581939b5ea24ebcf2c3edd Mon Sep 17 00:00:00 2001 From: Michieal Date: Sun, 29 Jan 2023 13:12:24 -0500 Subject: [PATCH 9/9] Fixed noted errors from Pull Request. --- mods/ITEMS/mcl_starting_inventory/init.lua | 4 ++-- mods/ITEMS/mcl_starting_inventory/mod.conf | 6 +++--- settingtypes.txt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_starting_inventory/init.lua b/mods/ITEMS/mcl_starting_inventory/init.lua index dfd2ba6db..137391bd3 100644 --- a/mods/ITEMS/mcl_starting_inventory/init.lua +++ b/mods/ITEMS/mcl_starting_inventory/init.lua @@ -11,7 +11,7 @@ local function mcl_log(message) end end -local give_inventory = minetest.settings:get("starting_inv_contents", false) +local give_inventory = minetest.settings:get_bool("give_starting_inv", false) local stuff_string = "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 32" @@ -54,7 +54,7 @@ function mcl_starting_inventory.get_list() return mcl_starting_inventory.items end -if give_inventory then +if give_inventory and give_inventory == true then mcl_starting_inventory.add_from_csv(stuff_string) mcl_log("Okay to give inventory:\n" .. dump(mcl_starting_inventory.get_list())) end diff --git a/mods/ITEMS/mcl_starting_inventory/mod.conf b/mods/ITEMS/mcl_starting_inventory/mod.conf index de938b831..e24d4522d 100644 --- a/mods/ITEMS/mcl_starting_inventory/mod.conf +++ b/mods/ITEMS/mcl_starting_inventory/mod.conf @@ -1,3 +1,3 @@ -name = mcl_starting_inventory -description = Mineclone 2 mod, Starting Inventory -depends = mcl_core, mcl_tools, +title = mcl_starting_inventory +description = Mineclone 2 mod, Give Starting Inventory +depends = mcl_core, mcl_tools, mcl_torches diff --git a/settingtypes.txt b/settingtypes.txt index 3644a70a1..8a891ea8e 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -236,8 +236,8 @@ mcl_extended_pet_control (Extended pet control) bool true # Enable hamburgers for villagers to follow mcl_enable_hamburger (Enable Hamburger) bool true -# Starting Inventory contents (given directly to the new player) type: string -starting_inv_contents (Player Starter Pack) bool false +# Starting Inventory contents (given directly to the new player) type: bool +give_starting_inv (Player Starter Pack) bool false [Debugging] # If enabled, this will show the itemstring of an item in the description.