Maciej Kasatkin
2012-09-23 2dc24b298406d9599754cf953a52b3aa9fe0c4e8
commit | author | age
167434 1 minetest.register_node( "technic:mineral_diamond", {
MK 2     description = "Diamond Ore",
77007b 3     tiles = { "default_stone.png^technic_mineral_diamond.png" },
167434 4     is_ground_content = true,
MK 5     groups = {cracky=3},
6     sounds = default.node_sound_stone_defaults(),
7     drop = 'craft "technic:diamond" 1',
8 }) 
9
10 minetest.register_craftitem( "technic:diamond", {
11     description = "Diamond",
12     inventory_image = "technic_diamond.png",
13     on_place_on_ground = minetest.craftitem_place_item,
14 })
77007b 15
MK 16 minetest.register_node( "technic:mineral_uranium", {
17     description = "Uranium Ore",
18     tiles = { "default_stone.png^technic_mineral_uranium.png" },
19     is_ground_content = true,
20     groups = {cracky=3},
21     sounds = default.node_sound_stone_defaults(),
22     drop = 'craft "technic:uranium" 1',
23 }) 
24
25 minetest.register_craftitem( "technic:uranium", {
26     description = "Uranium",
27     inventory_image = "technic_uranium.png",
28     on_place_on_ground = minetest.craftitem_place_item,
29 })
30
31 minetest.register_node( "technic:mineral_chromium", {
32     description = "Chromium Ore",
33     tiles = { "default_stone.png^technic_mineral_chromium.png" },
34     is_ground_content = true,
35     groups = {cracky=3},
36     sounds = default.node_sound_stone_defaults(),
37     drop = 'craft "technic:chromium_lump" 1',
38 }) 
39
40 minetest.register_craftitem( "technic:chromium_lump", {
41     description = "Chromium Lump",
42     inventory_image = "technic_chromium_lump.png",
43     on_place_on_ground = minetest.craftitem_place_item,
44 })
45
46 minetest.register_craftitem( "technic:chromium_ingot", {
47     description = "Chromium Ingot",
48     inventory_image = "technic_chromium_ingot.png",
49     on_place_on_ground = minetest.craftitem_place_item,
50 })
51
1f1562 52 minetest.register_craftitem( "technic:stainless_steel_ingot", {
MK 53     description = "Stainless Steel Ingot",
54     inventory_image = "technic_stainless_steel_ingot.png",
55     on_place_on_ground = minetest.craftitem_place_item,
56 })
57
77007b 58 minetest.register_craft({
MK 59                 type = 'cooking',
60                 output = "technic:chromium_ingot",
61                 recipe = "technic:chromium_lump"
62             })
167434 63
MK 64 local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
65     if maxp.y < height_min or minp.y > height_max then
66         return
67     end
68     local y_min = math.max(minp.y, height_min)
69     local y_max = math.min(maxp.y, height_max)
70     local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
71     local pr = PseudoRandom(seed)
72     local num_chunks = math.floor(chunks_per_volume * volume)
73     local chunk_size = 3
74     if ore_per_chunk <= 4 then
75         chunk_size = 2
76     end
77     local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
78     --print("generate_ore num_chunks: "..dump(num_chunks))
79     for i=1,num_chunks do
80     if (y_max-chunk_size+1 <= y_min) then return end
81         local y0 = pr:next(y_min, y_max-chunk_size+1)
82         if y0 >= height_min and y0 <= height_max then
83             local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
84             local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
85             local p0 = {x=x0, y=y0, z=z0}
86             for x1=0,chunk_size-1 do
87             for y1=0,chunk_size-1 do
88             for z1=0,chunk_size-1 do
89                 if pr:next(1,inverse_chance) == 1 then
90                     local x2 = x0+x1
91                     local y2 = y0+y1
92                     local z2 = z0+z1
93                     local p2 = {x=x2, y=y2, z=z2}
94                     if minetest.env:get_node(p2).name == wherein then
95                         minetest.env:set_node(p2, {name=name})
96                     end
97                 end
98             end
99             end
100             end
101         end
102     end
103     --print("generate_ore done")
104 end
105
106 minetest.register_on_generated(function(minp, maxp, seed)
32bd35 107 generate_ore("technic:mineral_diamond", "default:stone", minp, maxp, seed+20,   1/11/11/11,    2, -31000,  -450)
MK 108 generate_ore("technic:mineral_uranium", "default:stone", minp, maxp, seed+20,   1/11/11/11,    1, -300,  -100)
109 generate_ore("technic:mineral_chromium", "default:stone", minp, maxp, seed+30,   1/10/10/10,    2, -31000,  -100)
167434 110 end)