Maciej Kasatkin
2012-10-03 804887858c99b4c717d1591d8ecdc44eba6f4b5d
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
52 minetest.register_craft({
53                 type = 'cooking',
54                 output = "technic:chromium_ingot",
55                 recipe = "technic:chromium_lump"
56             })
804887 57
MK 58 minetest.register_craftitem( "technic:stainless_steel_ingot", {
59     description = "Stainless Steel Ingot",
60     inventory_image = "technic_stainless_steel_ingot.png",
61 })
62
63 minetest.register_node( "technic:mineral_zinc", {
64     description = "Zinc Ore",
65     tile_images = { "default_stone.png^technic_mineral_zinc.png" },
66     is_ground_content = true,
67     groups = {cracky=3},
68     sounds = default.node_sound_stone_defaults(),
69     drop = 'craft "technic:zinc_lump" 1',
70 })
71
72 minetest.register_craftitem( "technic:zinc_lump", {
73     description = "Zinc Lump",
74     inventory_image = "technic_zinc_lump.png",
75 })
76
77 minetest.register_craftitem( "technic:zinc_ingot", {
78     description = "Zinc Ingot",
79     inventory_image = "technic_zinc_ingot.png",
80 })
81
82 minetest.register_craft({
83                 type = 'cooking',
84                 output = "technic:zinc_ingot",
85                 recipe = "technic:zinc_lump"
86             })
87
167434 88
MK 89 local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
90     if maxp.y < height_min or minp.y > height_max then
91         return
92     end
93     local y_min = math.max(minp.y, height_min)
94     local y_max = math.min(maxp.y, height_max)
95     local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
96     local pr = PseudoRandom(seed)
97     local num_chunks = math.floor(chunks_per_volume * volume)
98     local chunk_size = 3
99     if ore_per_chunk <= 4 then
100         chunk_size = 2
101     end
102     local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
103     --print("generate_ore num_chunks: "..dump(num_chunks))
104     for i=1,num_chunks do
105     if (y_max-chunk_size+1 <= y_min) then return end
106         local y0 = pr:next(y_min, y_max-chunk_size+1)
107         if y0 >= height_min and y0 <= height_max then
108             local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
109             local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
110             local p0 = {x=x0, y=y0, z=z0}
111             for x1=0,chunk_size-1 do
112             for y1=0,chunk_size-1 do
113             for z1=0,chunk_size-1 do
114                 if pr:next(1,inverse_chance) == 1 then
115                     local x2 = x0+x1
116                     local y2 = y0+y1
117                     local z2 = z0+z1
118                     local p2 = {x=x2, y=y2, z=z2}
119                     if minetest.env:get_node(p2).name == wherein then
120                         minetest.env:set_node(p2, {name=name})
121                     end
122                 end
123             end
124             end
125             end
126         end
127     end
128     --print("generate_ore done")
129 end
130
131 minetest.register_on_generated(function(minp, maxp, seed)
804887 132 generate_ore("technic:mineral_diamond", "default:stone", minp, maxp, seed+21,   1/11/11/11,    2, -31000,  -450)
MK 133 generate_ore("technic:mineral_uranium", "default:stone", minp, maxp, seed+22,   1/11/11/11,    1, -300,  -100)
134 generate_ore("technic:mineral_chromium", "default:stone", minp, maxp, seed+23,   1/10/10/10,    2, -31000,  -100)
135 generate_ore("technic:mineral_zinc", "default:stone", minp, maxp, seed+24,   1/9/9/9,    5, -31000,  2)
167434 136 end)