Add hot spikes. Bias ores toward bad zones.
This commit is contained in:
parent
87fbc5256c
commit
0780d8dd67
4 changed files with 124 additions and 16 deletions
23
init.lua
23
init.lua
|
@ -15,6 +15,7 @@ minetest.register_on_mapgen_init(function(mgparams)
|
|||
end)
|
||||
|
||||
|
||||
fun_caves.ores = {}
|
||||
if default then
|
||||
if default.register_ores then
|
||||
default.register_ores()
|
||||
|
@ -35,6 +36,8 @@ if default then
|
|||
local ores = {}
|
||||
for id, ore_table in pairs(minetest.registered_ores) do
|
||||
local ore = table.copy(ore_table)
|
||||
local ore2 = table.copy(ore_table)
|
||||
table.insert(fun_caves.ores, ore2)
|
||||
ore.y_min = -31000
|
||||
ore.y_max = 31000
|
||||
table.insert(ores, ore)
|
||||
|
@ -47,6 +50,26 @@ if default then
|
|||
end
|
||||
|
||||
|
||||
function fun_caves.set_ores(biome)
|
||||
local ores = fun_caves.ores
|
||||
|
||||
--print("generating ores based on biome: "..biome)
|
||||
local y_factor = (math.abs(biome) - 0.4) * -3500
|
||||
--print("y_factor: "..y_factor)
|
||||
|
||||
minetest.clear_registered_ores()
|
||||
for id, ore_table in pairs(ores) do
|
||||
local ore = table.copy(ore_table)
|
||||
if ore.y_max >= y_factor then
|
||||
--print("using ore: "..ore.ore..", y_max: "..ore.y_max)
|
||||
ore.y_min = -31000
|
||||
ore.y_max = 31000
|
||||
minetest.register_ore(ore)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Check if the table contains an element.
|
||||
function table.contains(table, element)
|
||||
for key, value in pairs(table) do
|
||||
|
|
36
mapgen.lua
36
mapgen.lua
|
@ -180,26 +180,13 @@ function fun_caves.generate(p_minp, p_maxp, seed)
|
|||
local px = math.floor((minp.x + 32) / csize.x)
|
||||
local pz = math.floor((minp.z + 32) / csize.z)
|
||||
|
||||
-- Fill with stone.
|
||||
for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local ivm = area:index(minp.x, y, z)
|
||||
for x = minp.x, maxp.x do
|
||||
data[ivm] = node("default:stone")
|
||||
ivm = ivm + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
minetest.generate_ores(vm, minp, maxp)
|
||||
vm:get_data(data)
|
||||
|
||||
local cave_1 = minetest.get_perlin_map(cave_noise_1, csize):get3dMap_flat(minp)
|
||||
local cave_2 = minetest.get_perlin_map(cave_noise_2, csize):get3dMap_flat(minp)
|
||||
local biome_n = minetest.get_perlin_map(biome_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||
local biome_bn = minetest.get_perlin_map(biome_blend, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||
|
||||
local biome_avg = 0
|
||||
local biome_ct = 0
|
||||
local index = 0
|
||||
local index3d = 0
|
||||
for z = minp.z, maxp.z do
|
||||
|
@ -218,14 +205,26 @@ function fun_caves.generate(p_minp, p_maxp, seed)
|
|||
|
||||
if n1 * n2 > 0.05 then
|
||||
data[ivm] = node("air")
|
||||
else
|
||||
data[ivm] = node("default:stone")
|
||||
end
|
||||
|
||||
local biome_val = biome_n[index] + biome_bn[index]
|
||||
biome_avg = biome_avg + biome_val
|
||||
biome_ct = biome_ct + 1
|
||||
|
||||
ivm = ivm + area.ystride
|
||||
index3d = index3d + csize.x
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
biome_avg = biome_avg / biome_ct
|
||||
fun_caves.set_ores(biome_avg)
|
||||
minetest.generate_ores(vm, minp, maxp)
|
||||
vm:get_data(data)
|
||||
|
||||
local index = 0
|
||||
local index3d = 0
|
||||
for z = minp.z, maxp.z do
|
||||
|
@ -315,6 +314,12 @@ function fun_caves.generate(p_minp, p_maxp, seed)
|
|||
data[ivm] = node("fun_caves:stalactite")
|
||||
end
|
||||
-- standing up
|
||||
elseif data[ivm_below] == node("fun_caves:hot_cobble") and sr < 20 then
|
||||
if sr < 10 then
|
||||
data[ivm] = node("fun_caves:hot_spike")
|
||||
else
|
||||
data[ivm] = node("fun_caves:hot_spike_"..(math.ceil(sr / 3) - 2))
|
||||
end
|
||||
elseif data[ivm_below] == node("default:coalblock") and sr < 20 then
|
||||
data[ivm] = node("fun_caves:constant_flame")
|
||||
elseif data[ivm_below] == node("default:ice") and sr < 80 then
|
||||
|
@ -365,7 +370,6 @@ function fun_caves.generate(p_minp, p_maxp, seed)
|
|||
|
||||
|
||||
vm:set_data(data)
|
||||
minetest.generate_ores(vm, minp, maxp)
|
||||
--vm:set_param2_data(p2data)
|
||||
if DEBUG then
|
||||
vm:set_lighting({day = 15, night = 15})
|
||||
|
|
81
nodes.lua
81
nodes.lua
|
@ -588,3 +588,84 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
--stone spike
|
||||
local spike_size = { 1.0, 1.2, 1.4, 1.6, 1.7 }
|
||||
local hot_spikes = {}
|
||||
|
||||
for i in ipairs(spike_size) do
|
||||
if i == 1 then
|
||||
nodename = "fun_caves:hot_spike"
|
||||
else
|
||||
nodename = "fun_caves:hot_spike_"..i
|
||||
end
|
||||
|
||||
hot_spikes[#hot_spikes+1] = nodename
|
||||
|
||||
vs = spike_size[i]
|
||||
|
||||
minetest.register_node(nodename, {
|
||||
description = "Stone Spike",
|
||||
tiles = {"fun_caves_hot_spike.png"},
|
||||
inventory_image = "fun_caves_hot_spike.png",
|
||||
wield_image = "fun_caves_hot_spike.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
light_source = 3,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = vs,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5*vs, -0.5*vs, -0.5*vs, 0.5*vs, -5/16*vs, 0.5*vs},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- Spike spread and death
|
||||
minetest.register_abm({
|
||||
nodenames = hot_spikes,
|
||||
neighbors = {"default:lava_source", "default:lava_flowing"},
|
||||
interval = 6 * fun_caves.time_factor,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local spike_num
|
||||
for i = 1, #hot_spikes do
|
||||
if hot_spikes[i] == node.name then
|
||||
spike_num = i
|
||||
end
|
||||
end
|
||||
if not spike_num then
|
||||
return
|
||||
end
|
||||
|
||||
if spike_num < #hot_spikes then
|
||||
minetest.set_node(pos, {name=hot_spikes[spike_num+1]})
|
||||
return
|
||||
end
|
||||
|
||||
local random = {
|
||||
x = pos.x + math.random(-2, 2),
|
||||
y = pos.y + math.random(-1, 1),
|
||||
z = pos.z + math.random(-2, 2)
|
||||
}
|
||||
local random_node = minetest.get_node_or_nil(random)
|
||||
if not random_node or (random_node.name ~= "air" and random_node.name ~= "default:lava_source" and random_node.name ~= "default:lava_flowing") then
|
||||
return
|
||||
end
|
||||
local node_under = minetest.get_node_or_nil({x = random.x,
|
||||
y = random.y - 1, z = random.z})
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
|
||||
print("node_under ("..random.x..","..(random.y-1)..","..random.z.."): "..node_under.name)
|
||||
if node_under.name == "fun_caves:hot_cobble" or node_under.name == "default:coalblock" then
|
||||
print("setting ("..random.x..","..random.y..","..random.z.."): "..node_under.name)
|
||||
minetest.set_node(random, {name = hot_spikes[1]})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
|
BIN
textures/fun_caves_hot_spike.png
Normal file
BIN
textures/fun_caves_hot_spike.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 724 B |
Loading…
Add table
Add a link
Reference in a new issue