add fine floor fungus, variety to the lava sea

This commit is contained in:
FaceDeer 2018-05-31 01:34:22 -06:00
parent 858a907098
commit da4ab38b4f
6 changed files with 164 additions and 28 deletions

View File

@ -10,55 +10,89 @@ local c_mesecry = minetest.get_content_id("dfcaverns:glow_mese")
-------------------------------------------------------------------------------------------
local lava_ceiling = function(area, data, ai, vi, bi)
if math.random() < 0.005 then
subterrane:giant_stalactite(ai, area, data, 6, 13, c_meseore, c_meseore, c_mesecry)
local mese_crystal_ceiling = function(area, data, ai, vi, bi)
if math.random() < 0.025 then
if math.random() < 0.25 then
subterrane:giant_stalactite(ai, area, data, 6, 13, c_meseore, c_meseore, c_mesecry)
else
data[vi] = c_meseore
if math.random() < 0.25 then
data[bi] = c_mesecry
end
end
end
end
local mese_ore_ceiling = function(area, data, ai, vi, bi)
if math.random() < 0.025 then
data[vi] = c_meseore
if math.random() < 0.25 then
data[bi] = c_mesecry
end
end
end
local mese_ore_floor = function(area, data, ai, vi, bi)
if math.random() < 0.01 then
data[vi] = c_meseore
if math.random() < 0.25 then
data[ai] = c_mesecry
end
end
end
local lava_sea_biome_def = {
local lava_sea_crystal_biome_def = {
name = "dfcaverns_lava_sea_with_mese_crystal",
y_min = dfcaverns.config.lava_sea_min,
y_max = dfcaverns.config.lava_sea_max,
heat_point = 80,
humidity_point = 20,
_subterrane_ceiling_decor = mese_crystal_ceiling,
_subterrane_floor_decor = mese_ore_floor,
}
local lava_sea_mese_biome_def = {
name = "dfcaverns_lava_sea_with_mese",
y_min = dfcaverns.config.lava_sea_min,
y_max = dfcaverns.config.lava_sea_max,
heat_point = 60,
humidity_point = 40,
_subterrane_ceiling_decor = mese_ore_ceiling,
}
local lava_sea_barren_biome_def = {
name = "dfcaverns_lava_sea",
y_min = dfcaverns.config.lava_sea_min,
y_max = dfcaverns.config.lava_sea_max,
heat_point = 50,
heat_point = 40,
humidity_point = 50,
_subterrane_ceiling_decor = lava_ceiling,
}
minetest.register_biome(lava_sea_biome_def)
local airspace = (dfcaverns.config.lava_sea_max - dfcaverns.config.lava_sea_min) / 3
minetest.register_biome(lava_sea_crystal_biome_def)
minetest.register_biome(lava_sea_mese_biome_def)
minetest.register_biome(lava_sea_barren_biome_def)
local airspace = (dfcaverns.config.lava_sea_max - dfcaverns.config.lava_sea_min) / 2.75
local lava_sea_level = dfcaverns.config.lava_sea_max - airspace
local data = {}
minetest.register_on_generated(function(minp, maxp, seed)
--if out of range of cave definition limits, abort
if minp.y > dfcaverns.config.lava_sea_max - airspace or maxp.y < dfcaverns.config.lava_sea_min then
if minp.y > lava_sea_level or maxp.y < dfcaverns.config.lava_sea_min then
return
end
--easy reference to commonly used values
local t_start = os.clock()
local x_max = maxp.x
local y_max = maxp.y
local z_max = maxp.z
local x_min = minp.x
local y_min = minp.y
local z_min = minp.z
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
vm:get_data(data)
for z = z_min, z_max do -- for each xy plane progressing northwards
for y = y_min, y_max do -- for each x row progressing upwards
local vi = area:index(x_min, y, z) --current node index
for x = x_min, x_max do -- for each node do
if data[vi] == c_air or data[vi] == c_water then
data[vi] = c_lava
end
vi = vi + 1
for vi, x, y, z in area:iterp_xyz(minp, maxp) do
if y < lava_sea_level + math.random(0,3) then
if data[vi] == c_air or data[vi] == c_water then
data[vi] = c_lava
end
end
end
@ -68,6 +102,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
--calc lighting
vm:set_lighting({day = 0, night = 0})
vm:calc_lighting()
vm:update_liquids()
--write it to world
vm:write_to_map()
end)

View File

@ -63,11 +63,35 @@ minetest.register_node("dfcaverns:cobble_with_floor_fungus", {
}),
})
minetest.register_node("dfcaverns:cobble_with_floor_fungus_fine", {
description = S("Cobblestone With Floor Fungus"),
_doc_items_longdesc = dfcaverns.doc.floor_fungus_desc,
_doc_items_usagehelp = dfcaverns.doc.floor_fungus_usage,
tiles = {"default_cobble.png^dfcaverns_floor_fungus_fine.png"},
drops = "default:cobble",
is_ground_content = true,
groups = {cracky = 3, stone = 2, slippery = 1, light_sensitive_fungus = 11},
_dfcaverns_dead_node = "default:cobble",
sounds = default.node_sound_stone_defaults({
footstep = {name = "dfcaverns_squish", gain = 0.25},
}),
})
minetest.register_abm{
label = "dfcaverns:floor_fungus_spread",
nodenames = {"default:cobble"},
neighbors = {"dfcaverns:cobble_with_floor_fungus"},
interval = 60,
chance = 5,
catch_up = true,
action = function(pos)
minetest.swap_node(pos, {name="dfcaverns:cobble_with_floor_fungus_fine"})
end,
}
minetest.register_abm{
label = "dfcaverns:floor_fungus_thickening",
nodenames = {"default:cobble_with_floor_fungus_fine"},
interval = 59,
chance = 30,
catch_up = true,
action = function(pos)

View File

@ -6,6 +6,7 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
--load companion lua files
dofile(modpath.."/config.lua")
dofile(modpath.."/doc.lua")
dofile(modpath.."/voxelarea_iterator.lua")
dofile(modpath.."/features/ground_cover.lua")
dofile(modpath.."/features/glow_worms.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

75
voxelarea_iterator.lua Normal file
View File

@ -0,0 +1,75 @@
-- These functions are a minor modification of the voxel area iterator defined in the built in voxelarea.lua lua code.
-- As such, this file is separately licened under the LGPL as follows:
-- License of Minetest source code
-------------------------------
--Minetest
--Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
function VoxelArea:iter_xyz(minx, miny, minz, maxx, maxy, maxz)
local i = self:index(minx, miny, minz) - 1
local x = minx - 1 -- subtracting one because x gets incremented before it gets returned the first time.
local xrange = maxx - minx + 1
local nextaction = i + 1 + xrange
local y = 0
local yrange = maxy - miny + 1
local yreqstride = self.ystride - xrange
local z = 0
local zrange = maxz - minz + 1
local multistride = self.zstride - ((yrange - 1) * self.ystride + xrange)
return function()
-- continue i until it needs to jump
i = i + 1
x = x + 1
if i ~= nextaction then
return i, x, y+miny, z+minz
end
-- continue y until maxy is exceeded
y = y + 1
x = minx -- new line
if y ~= yrange then
-- set i to index(minx, miny + y, minz + z) - 1
i = i + yreqstride
nextaction = i + xrange
return i, x, y+miny, z+minz
end
-- continue z until maxz is exceeded
z = z + 1
if z == zrange then
-- cuboid finished, return nil
return
end
-- set i to index(minx, miny, minz + z) - 1
i = i + multistride
y = 0
nextaction = i + xrange
return i, x, y+miny, z+minz
end
end
function VoxelArea:iterp_xyz(minp, maxp)
return self:iter_xyz(minp.x, minp.y, minp.z, maxp.x, maxp.y, maxp.z)
end