123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- --------------------------------------------------------------------------------
- -- Gem Tools Mod for Must Test Survival
- -- Author: GoldFireUn
- -- License of Source Code: MIT
- -- License of Media: CC BY-SA 3.0
- --------------------------------------------------------------------------------
- gem_tools = gem_tools or {}
- gem_tools.modpath = minetest.get_modpath("gem_tools")
- -- This code is executed only once.
- if not gem_tools.registered then
- local function register_sword(material, result, reinforced)
- minetest.register_craft({
- output = result,
- recipe = {
- {'', material, ''},
- {'farming:string', material, 'farming:string'},
- {'', 'default:sword_steel', ''},
- }
- })
- minetest.register_craft({
- output = reinforced,
- recipe = {
- {'', material, ''},
- {'farming:string', material, 'farming:string'},
- {'', 'titanium:sword', ''},
- }
- })
- end
- local function register_pick(material, result, reinforced)
- minetest.register_craft({
- output = result,
- recipe = {
- {material, material, material},
- {'', 'farming:string', ''},
- {'', 'default:pick_steel', ''},
- }
- })
- minetest.register_craft({
- output = reinforced,
- recipe = {
- {material, material, material},
- {'', 'farming:string', ''},
- {'', 'titanium:pick', ''},
- }
- })
- end
- local function register_axe(material, result, reinforced)
- minetest.register_craft({
- output = result,
- recipe = {
- {material, material, ''},
- {material, 'farming:string', ''},
- {'', 'default:axe_steel', ''},
- }
- })
- minetest.register_craft({
- output = result,
- recipe = {
- {'', material, material},
- {'', 'farming:string', material},
- {'', 'default:axe_steel', ''},
- }
- })
- minetest.register_craft({
- output = reinforced,
- recipe = {
- {material, material, ''},
- {material, 'farming:string', ''},
- {'', 'titanium:axe', ''},
- }
- })
- minetest.register_craft({
- output = reinforced,
- recipe = {
- {'', material, material},
- {'', 'farming:string', material},
- {'', 'titanium:axe', ''},
- }
- })
- end
- local function register_shovel(material, result, reinforced)
- minetest.register_craft({
- output = result,
- recipe = {
- {material},
- {'farming:string'},
- {'default:shovel_steel'},
- }
- })
- minetest.register_craft({
- output = reinforced,
- recipe = {
- {material},
- {'farming:string'},
- {'titanium:shovel'},
- }
- })
- end
- local gems = {
- {name="ruby", desc="Ruby"},
- {name="amethyst", desc="Amethyst"},
- {name="sapphire", desc="Sapphire"},
- {name="emerald", desc="Emerald"},
- }
- local tools = {
- {tool="pick", desc="Pickaxe", register=register_pick},
- {tool="sword", desc="Sword", register=register_sword},
- {tool="axe", desc="Axe", register=register_axe},
- {tool="shovel", desc="Shovel", register=register_shovel},
- }
- for k, v in ipairs(gems) do
- for i, j in ipairs(tools) do
- local material = "gems:" .. v.name .. "_gem"
- local tool = "gems:" .. j.tool .. "_" .. v.name
- local tool_rf_old = "gems:stone_" .. j.tool .. "_" .. v.name
- local tool_rf = "gems:rf_" .. j.tool .. "_" .. v.name
- local desc = v.desc .. " " .. j.desc
- local desc_rf = v.desc .. " " .. j.desc .. " (Reinforced Handle)"
- local data = j.tool .. "_" .. v.name
- local data_rf = j.tool .. "_" .. v.name .. "_rf"
- local iimg = "gem_tools_" .. v.name .. "_" .. j.tool .. ".png"
- local iimg_rf = "gem_tools_rf_" .. v.name .. "_" .. j.tool .. ".png"
- -- Ensure tooldata exists.
- assert(tooldata[data])
- assert(tooldata[data_rf])
- minetest.register_tool(":" .. tool, {
- description = desc,
- inventory_image = iimg,
- tool_capabilities = tooldata[data],
- groups = {gem_tool=1},
- })
- minetest.register_tool(":" .. tool_rf, {
- description = desc_rf,
- inventory_image = iimg_rf,
- tool_capabilities = tooldata[data_rf],
- groups = {gem_tool=1},
- })
- -- Register craft recipes.
- j.register(material, tool, tool_rf)
- -- Alias old tools.
- minetest.register_alias(tool_rf_old, tool_rf)
- end
- end
- -- Give players back their steel ingots.
- minetest.register_alias("gems:stone_rod", "default:steel_ingot")
- local c = "gem_tools:core"
- local f = gem_tools.modpath .. "/init.lua"
- reload.register_file(c, f, false)
- gem_tools.registered = true
- end
|