/
init.lua
107 lines (100 loc) · 3.25 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
addore = function(mn,oreName, oreDescription, oreTexture, oreMaterial,
digTools,
maxAmountForChunk, rarity, size,
minY, maxY,
dropName, dropDescription, dropTexture, dropAmount)
local ore = mn .. ":" .. oreName
local oreNode = {
description = oreDescription,
tiles = {oreTexture},
is_ground_content = true,
material = oreMaterial
}
if dropName ~= nil then
local drop = ""
if dropName ~= "" then
drop = mn .. ":" .. dropName
minetest.register_craftitem(drop, {
description = dropDescription,
image = dropTexture
})
end
oreNode["drop"] = {
max_items = 1,
items = {
{
items = {drop.." "..dropAmount},
tools = digTools
}
}
}
end
minetest.register_node(ore, oreNode)
local gen = function(minp,maxp)
if minp.y < minY or maxp.y > maxY or math.random(1, rarity) ~= 1 then
return
end
for a = 0, maxAmountForChunk do
local pos = {
x = math.random( minp.x, maxp.x ),
y = math.random( minp.y, maxp.y ),
z = math.random( minp.z, maxp.z ),
}
for i = -1, size.x - 1 do
for j = -1, size.y - 1 do
for k = -1, size.z - 1 do
if math.random(1, 5) > 2 then
else
local p = {x = pos.x + i, y = pos.y + j, z = pos.z + k}
local n = minetest.env:get_node(p)
if n.name == "default:stone" then
minetest.env:add_node(p, {name = ore})
end
end
end
end
end
end
end
minetest.register_on_generated(gen)
end
--[[ example
addore("check_ore","BAD ORE",
"check_ore.png",minetest.digprop_stonelike(1.4),
nil, -- any tool
50,
1,{
x = 1,
y = 1,
z = 1,
},
-31000,100)
]]--
-- quick iron add
local gen = function(minp,maxp)
if minp.y < -31000 or maxp.y > -120 or math.random(1, 8) ~= 1 then
return
end
for a = 0, 2 do
local pos = {
x = math.random( minp.x, maxp.x ),
y = math.random( minp.y, maxp.y ),
z = math.random( minp.z, maxp.z ),
}
for i = -1, 4 - 1 do
for j = -1, 3 - 1 do
for k = -1, 3 - 1 do
if math.random(1, 5) > 2 then
else
local p = {x = pos.x + i, y = pos.y + j, z = pos.z + k}
local n = minetest.env:get_node(p)
if n.name == "default:stone" then
minetest.env:add_node(p, {name = "default:stone_with_iron"})
end
end
end
end
end
end
end
minetest.register_on_generated(gen)