feat: add mineclone support basically(can extends the quiz_mineclone_items.yml)

master
Riceball LEE 2021-07-18 22:06:11 +08:00
parent a17d510ac9
commit 0f8dce9dc0
No known key found for this signature in database
GPG Key ID: 10F15E84852CB868
2 changed files with 28 additions and 2 deletions

View File

@ -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

12
mineclone_items.yml Normal file
View File

@ -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"