From 0f8dce9dc0c21bc2ef51684fcab24117b13dec2c Mon Sep 17 00:00:00 2001 From: Riceball LEE Date: Sun, 18 Jul 2021 22:06:11 +0800 Subject: [PATCH] feat: add mineclone support basically(can extends the quiz_mineclone_items.yml) --- giveme_item.lua | 18 ++++++++++++++++-- mineclone_items.yml | 12 ++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 mineclone_items.yml diff --git a/giveme_item.lua b/giveme_item.lua index a8292ce..b040446 100644 --- a/giveme_item.lua +++ b/giveme_item.lua @@ -1,20 +1,34 @@ +local MOD_NAME = quiz.MOD_NAME local MOD_PATH = quiz.MOD_PATH local S = quiz.get_translator - +--< in Mineclone 2 game +local isMineClone = minetest.get_modpath("mcl_core") ~= nil local callChatCmd = dofile(MOD_PATH.."call_chat_cmd.lua") +local itemMapper + +if (isMineClone) then + itemMapper = yaml.readConfig(MOD_NAME, "mineclone_items.yml") +end + local function givemeItem(playerName, item) local name = item.id local modName = item.mod or "default" local count = item.count or 1 local title = item.title or name or "" local T = minetest.get_translator(modName) or S + local id = modName .. ":" .. name + local mcItem = itemMapper and itemMapper[id] + if mcItem then + id = mcItem.id + if mcItem.title then title = mcItem.title end + end -- local player = minetest.get_player_by_name(playerName) -- player:get_inventory():add_item('main', 'default:mese 1') -- print("giveme Item:", modName, name, dump(item)) - local result = callChatCmd("giveme", playerName, {modName .. ":" .. name, count}) + local result = callChatCmd("giveme", playerName, {id, count}) if not result then minetest.chat_send_player(playerName, S("Can't get '@1'", T(title))) else diff --git a/mineclone_items.yml b/mineclone_items.yml new file mode 100644 index 0000000..4723d7a --- /dev/null +++ b/mineclone_items.yml @@ -0,0 +1,12 @@ +# minetest_game to mineclone2 mapper +"default:coalblock": + id: "mcl_core:coalblock" +"default:wood": + id: "mcl_core:wood" +"default:stone": + id: "mcl_core:stone" +"default:torch": + id: "mcl_torches:torch" +"default:steel_ingot": + id: "mcl_core:iron_ingot" + title: "Iron Ingot"