Maciej Kasatkin
2012-09-02 d455791cfb2d93e3625c1db103f069fa11c3d566
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_node( "technic:diamond_block", {
41     description = "Diamond Block",
42     tiles = { "technic_diamond_block.png" },
43     is_ground_content = true,
44     groups = {cracky=3},
45     sounds = default.node_sound_stone_defaults(),
46     drop = 'craft "technic:diamond_block" 1',
47 }) 
48
49 minetest.register_node( "technic:diamond_block_red", {
50     description = "Red Diamond Block",
51     tiles = { "technic_diamond_block_red.png" },
52     is_ground_content = true,
53     groups = {cracky=3},
54     sounds = default.node_sound_stone_defaults(),
55     drop = 'craft "technic:diamond_block_red" 1',
56 }) 
57 minetest.register_node( "technic:diamond_block_green", {
58     description = "Green Diamond Block",
59     tiles = { "technic_diamond_block_green.png" },
60     is_ground_content = true,
61     groups = {cracky=3},
62     sounds = default.node_sound_stone_defaults(),
63     drop = 'craft "technic:diamond_block_green" 1',
64 }) 
65 minetest.register_node( "technic:diamond_block_blue", {
66     description = "Red Diamond Block",
67     tiles = { "technic_diamond_block_blue.png" },
68     is_ground_content = true,
69     groups = {cracky=3},
70     sounds = default.node_sound_stone_defaults(),
71     drop = 'craft "technic:diamond_block_blue" 1',
72 }) 
73
74
75 minetest.register_craftitem( "technic:chromium_lump", {
76     description = "Chromium Lump",
77     inventory_image = "technic_chromium_lump.png",
78     on_place_on_ground = minetest.craftitem_place_item,
79 })
80
81 minetest.register_craftitem( "technic:chromium_ingot", {
82     description = "Chromium Ingot",
83     inventory_image = "technic_chromium_ingot.png",
84     on_place_on_ground = minetest.craftitem_place_item,
85 })
86
87 minetest.register_craft({
88                 type = 'cooking',
89                 output = "technic:chromium_ingot",
90                 recipe = "technic:chromium_lump"
91             })
167434 92
MK 93 local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
94     if maxp.y < height_min or minp.y > height_max then
95         return
96     end
97     local y_min = math.max(minp.y, height_min)
98     local y_max = math.min(maxp.y, height_max)
99     local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
100     local pr = PseudoRandom(seed)
101     local num_chunks = math.floor(chunks_per_volume * volume)
102     local chunk_size = 3
103     if ore_per_chunk <= 4 then
104         chunk_size = 2
105     end
106     local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
107     --print("generate_ore num_chunks: "..dump(num_chunks))
108     for i=1,num_chunks do
109     if (y_max-chunk_size+1 <= y_min) then return end
110         local y0 = pr:next(y_min, y_max-chunk_size+1)
111         if y0 >= height_min and y0 <= height_max then
112             local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
113             local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
114             local p0 = {x=x0, y=y0, z=z0}
115             for x1=0,chunk_size-1 do
116             for y1=0,chunk_size-1 do
117             for z1=0,chunk_size-1 do
118                 if pr:next(1,inverse_chance) == 1 then
119                     local x2 = x0+x1
120                     local y2 = y0+y1
121                     local z2 = z0+z1
122                     local p2 = {x=x2, y=y2, z=z2}
123                     if minetest.env:get_node(p2).name == wherein then
124                         minetest.env:set_node(p2, {name=name})
125                     end
126                 end
127             end
128             end
129             end
130         end
131     end
132     --print("generate_ore done")
133 end
134
135 minetest.register_on_generated(function(minp, maxp, seed)
136 generate_ore("technic:mineral_diamond", "default:stone", minp, maxp, seed+20,   1/11/11/11,    1, -31000,  -450)
77007b 137 generate_ore("technic:mineral_uranium", "default:stone", minp, maxp, seed+20,   1/11/11/11,    1, -300,  -150)
MK 138 generate_ore("technic:mineral_chromium", "default:stone", minp, maxp, seed+20,   1/13/13/13,    1, -600,  -100)
167434 139 end)