Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile(minetest.get_modpath("gems").."/config.lua")
- minetest.register_node("gems:mineral_ruby", {
- description = "Ruby Ore",
- tiles = {"default_stone.png^gems_mineral_ore.png"},
- is_ground_content = true,
- groups = {cracky=3},
- drop = 'gems:ruby',
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_node("gems:mineral_sapphire", {
- description = "Sapphire Ore",
- tiles = {"default_stone.png^gems_mineral_sapphire.png"},
- is_ground_content = true,
- groups = {cracky=3},
- drop = 'gems:sapphire',
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_node("gems:mineral_emerald", {
- description = "Emerald Ore",
- tiles = {"default_stone.png^gems_mineral_emerald.png"},
- is_ground_content = true,
- groups = {cracky=3},
- drop = 'gems:emerald',
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_node("gems:mineral_diamond", {
- description = "Amethyst Ore",
- tiles = {"default_stone.png^gems_mineral_diamond.png"},
- is_ground_content = true,
- groups = {cracky=3},
- drop = 'gems:diamond',
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_node("gems:mineral_topaz", {
- description = "Topaz Ore",
- tiles = {"default_stone.png^gems_mineral_topaz.png"},
- is_ground_content = true,
- groups = {cracky=3},
- drop = 'gems:topaz',
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_craftitem("gems:ruby", {
- description = "Ruby",
- inventory_image = "gems_ruby.png",
- })
- minetest.register_craftitem("gems:sapphire", {
- description = "Sapphire",
- inventory_image = "gems_sapphire.png",
- })
- minetest.register_craftitem("gems:emerald", {
- description = "Emerald",
- inventory_image = "gems_emerald.png",
- })
- minetest.register_craftitem("gems:amethyst", {
- description = "Amethyst",
- inventory_image = "gems_amethyst.png",
- })
- minetest.register_craftitem("gems:topaz", {
- description = "Topaz",
- inventory_image = "gems_topaz.png",
- })
- encrust_a_tool = function(result,crafttool,craftgem)
- minetest.register_craft( {
- type = "shapeless",
- output = result,
- recipe = {
- crafttool,
- craftgem,
- },
- })
- end
- mods = {}
- metals = {}
- metalname = {}
- gems = {"ruby","sapphire","emerald","amethyst","topaz"}
- gemname = {"Ruby","Sapphire","Emerald","Amethyst","Topaz"}
- gembenefitspeed = {0.75,1.00,0.85,1.15,0.60}
- gembenefitwear = {1.00,1.35,1.25,1.50,0.80}
- if encrust_steel == true then
- table.insert(mods,"default")
- table.insert(metals,"steel")
- table.insert(metalname,"Steel")
- end
- if encrust_bronze == true then
- table.insert(mods,"moreores")
- table.insert(metals,"bronze")
- table.insert(metalname,"Bronze")
- end
- if encrust_silver == true then
- table.insert(mods,"moreores")
- table.insert(metals,"silver")
- table.insert(metalname,"Silver")
- end
- if encrust_gold == true then
- table.insert(mods,"moreores")
- table.insert(metals,"gold")
- table.insert(metalname,"Gold")
- end
- if encrust_mithril == true then
- table.insert(mods,"moreores")
- table.insert(metals,"mithril")
- table.insert(metalname,"Mithril")
- end
- if encrust_alatro == true then
- table.insert(mods,"gloopores")
- table.insert(metals,"alatro")
- table.insert(metalname,"Alatro")
- end
- if encrust_arol == true then
- table.insert(mods,"gloopores")
- table.insert(metals,"arol")
- table.insert(metalname,"Arol")
- end
- for j,k in ipairs(metals) do
- modis = mods[j]
- metalis = metals[j]
- pickdef = minetest.registered_tools[modis..":pick_"..metals[j]]
- axedef = minetest.registered_tools[modis..":axe_"..metals[j]]
- shoveldef = minetest.registered_tools[modis..":shovel_"..metals[j]]
- sworddef = minetest.registered_tools[modis..":sword_"..metals[j]]
- pickdig = pickdef.tool_capabilities.groupcaps.cracky
- axedigc = axedef.tool_capabilities.groupcaps.choppy
- axedigf = axedef.tool_capabilities.groupcaps.fleshy
- shoveldig = shoveldef.tool_capabilities.groupcaps.crumbly
- sworddigf = sworddef.tool_capabilities.groupcaps.fleshy
- sworddigs = sworddef.tool_capabilities.groupcaps.snappy
- sworddigc = sworddef.tool_capabilities.groupcaps.choppy
- for i,l in gems do
- npickdig = {}
- naxedigc = {}
- naxedigf = {}
- nshoveldig = {}
- nsworddigf = {}
- nsworddigs = {}
- nsworddigc = {}
- npickdig.times[1] = pickdig.times[1]*gembenefitspeed[i]
- npickdig.times[2] = pickdig.times[2]*gembenefitspeed[i]
- npickdig.times[3] = pickdig.times[3]*gembenefitspeed[i]
- npickdig.uses = pickdig.uses*gembenefitwear[i]
- naxedigc.times[1] = axedigc.times[1]*gembenefitspeed[i]
- naxedigc.times[2] = axedigc.times[2]*gembenefitspeed[i]
- naxedigc.times[3] = axedigc.times[3]*gembenefitspeed[i]
- naxedigc.uses = axedigc.uses*gembenefitwear[i]
- naxedigf.times[1] = axedigf.times[1]*gembenefitspeed[i]
- naxedigf.times[2] = axedigf.times[2]*gembenefitspeed[i]
- naxedigf.times[3] = axedigf.times[3]*gembenefitspeed[i]
- naxedigf.uses = axedigf.uses*gembenefitwear[i]
- nshoveldig.times[1] = shoveldig.times[1]*gembenefitspeed[i]
- nshoveldig.times[2] = shoveldig.times[2]*gembenefitspeed[i]
- nshoveldig.times[3] = shoveldig.times[3]*gembenefitspeed[i]
- nshoveldig.uses = shoveldig.uses*gembenefitwear[i]
- nsworddigf.times[1] = sworddigf.times[1]*gembenefitspeed[i]
- nsworddigf.times[2] = sworddigf.times[2]*gembenefitspeed[i]
- nsworddigf.times[3] = sworddigf.times[3]*gembenefitspeed[i]
- nsworddigf.uses = sworddigf.uses*gembenefitwear[i]
- nsworddigs.times[1] = sworddigs.times[1]*gembenefitspeed[i]
- nsworddigs.times[2] = sworddigs.times[2]*gembenefitspeed[i]
- nsworddigs.times[3] = sworddigs.times[3]*gembenefitspeed[i]
- nsworddigs.uses = sworddigs.uses*gembenefitwear[i]
- nsworddigc.times[1] = sworddigc.times[1]*gembenefitspeed[i]
- nsworddigc.times[2] = sworddigc.times[2]*gembenefitspeed[i]
- nsworddigc.times[3] = sworddigc.times[3]*gembenefitspeed[i]
- nsworddigc.uses = sworddigc.uses*gembenefitwear[i]
- minetest.register_tool("gems:pick_"..k.."_"..l, {
- description = gemname[i].."Encrusted "..metalname[j].." Pickaxe",
- inventory_image = mods[j].."_tool_"..metals[j].."pick.png^gems_pick_"..gems[i],
- tool_capabilities = {
- max_drop_level = pickdef.tool_capabilities.max_drop_level,
- groupcaps = {
- npickdig,
- }
- }
- })
- minetest.register_tool("gems:axe_"..k.."_"..i, {
- description = gemname[i].."Encrusted "..metalname[j].." Axe",
- inventory_image = mods[j].."_tool_"..metals[j].."axe.png^gems_axe_"..gems[i],
- tool_capabilities = {
- max_drop_level = axedef.tool_capabilities.max_drop_level,
- groupcaps = {
- naxedigc,
- naxedigf,
- }
- }
- })
- minetest.register_tool("gems:shovel_"..k.."_"..l, {
- description = gemname[i].."Encrusted "..metalname[j].." Shovel",
- inventory_image = mods[j].."_tool_"..metals[j].."shovel.png^gems_shovel_"..gems[i],
- tool_capabilities = {
- max_drop_level = shoveldef.tool_capabilities.max_drop_level,
- groupcaps = {
- nshoveldig,
- }
- }
- })
- minetest.register_tool("gems:sword_"..k.."_"..l, {
- description = gemname[i].."Encrusted "..metalname[j].." Sword",
- inventory_image = mods[j].."_tool_"..metals[j].."sword.png^gems_sword_"..gems[i],
- tool_capabilities = {
- max_drop_level = sworddef.tool_capabilities.max_drop_level,
- groupcaps = {
- nsworddigf,
- nsworddigs,
- nsworddigc,
- }
- }
- })
- minetest.register_craft({
- type = "shapeless",
- output = "gems:pick_"..k.."_"..l,
- recipe = {
- "gems:"..i,
- mods[j]..":pick_"..k,
- }
- })
- minetest.register_craft({
- type = "shapeless",
- output = "gems:axe_"..k.."_"..l,
- recipe = {
- "gems:"..i,
- mods[j]..":axe_"..k,
- }
- })
- minetest.register_craft({
- type = "shapeless",
- output = "gems:shovel_"..k.."_"..l,
- recipe = {
- "gems:"..i,
- mods[j]..":shovel_"..k,
- }
- })
- minetest.register_craft({
- type = "shapeless",
- output = "gems:sword_"..k.."_"..l,
- recipe = {
- "gems:"..i,
- mods[j]..":sword_"..k,
- }
- })
- end
- end
- local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
- if maxp.y < height_min or minp.y > height_max then
- return
- end
- local y_min = math.max(minp.y, height_min)
- local y_max = math.min(maxp.y, height_max)
- local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
- local pr = PseudoRandom(seed)
- local num_chunks = math.floor(chunks_per_volume * volume)
- local chunk_size = 3
- if ore_per_chunk <= 4 then
- chunk_size = 2
- end
- local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
- --print("generate_ore num_chunks: "..dump(num_chunks))
- for i=1,num_chunks do
- if (y_max-chunk_size+1 <= y_min) then return end
- local y0 = pr:next(y_min, y_max-chunk_size+1)
- if y0 >= height_min and y0 <= height_max then
- local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
- local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
- local p0 = {x=x0, y=y0, z=z0}
- for x1=0,chunk_size-1 do
- for y1=0,chunk_size-1 do
- for z1=0,chunk_size-1 do
- if pr:next(1,inverse_chance) == 1 then
- local x2 = x0+x1
- local y2 = y0+y1
- local z2 = z0+z1
- local p2 = {x=x2, y=y2, z=z2}
- if minetest.env:get_node(p2).name == wherein then
- minetest.env:set_node(p2, {name=name})
- end
- end
- end
- end
- end
- end
- end
- --print("generate_ore done")
- end
- minetest.register_on_generated(function(minp, maxp, seed)
- math.randomseed(os.time())
- local current_seed = seed + math.random(10,100)
- local function get_next_seed()
- current_seed = current_seed + 1
- return current_seed
- end
- generate_ore("gems:mineral_ruby", "default:stone", minp, maxp, get_next_seed(), 1/7/7/7, 1, -31000, -50)
- generate_ore("gems:mineral_sapphire", "default:stone", minp, maxp, get_next_seed(), 1/7/7/7, 1, -31000, -100)
- generate_ore("gems:mineral_emerald", "default:stone", minp, maxp, get_next_seed(), 1/7/7/7, 1, -31000, -150)
- generate_ore("gems:mineral_amethyst", "default:stone", minp, maxp, get_next_seed(), 1/7/7/7, 1, -31000, -200)
- generate_ore("gems:mineral_topaz", "default:stone", minp, maxp, get_next_seed(), 1/7/7/7, 1, -31000, -250)
- end)
- minetest.register_alias("gems:mineral_garnet","default:stone")
- minetest.register_alias("gems:mineral_aquamarine","default:stone")
- minetest.register_alias("gems:mineral_diamond","default:stone")
- minetest.register_alias("gems:mineral_opal","default:stone")
- print("[Gems] Loaded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement