2019-04-17 18:16:36 +02:00
|
|
|
--
|
|
|
|
-- Register biomes
|
|
|
|
--
|
|
|
|
|
2019-08-30 23:05:56 +02:00
|
|
|
--local read_csv = dofile(lib_materials.path .. "/csv.lua")
|
|
|
|
|
|
|
|
--local biomes = lib_materials.read_csv(lib_materials.path .. "/biomes.csv")
|
|
|
|
|
|
|
|
-- Define constants that can be used in csv
|
|
|
|
local heights = {
|
|
|
|
ocean_depth = lib_materials.ocean_depth,
|
|
|
|
beach_depth = lib_materials.beach_depth,
|
|
|
|
sea_level = lib_materials.sea_level,
|
|
|
|
beach = lib_materials.maxheight_beach,
|
|
|
|
coastal = lib_materials.maxheight_coastal,
|
|
|
|
lowland = lib_materials.maxheight_lowland,
|
|
|
|
shelf = lib_materials.maxheight_shelf,
|
|
|
|
highland = lib_materials.maxheight_highland,
|
|
|
|
mountain = lib_materials.maxheight_mountain,
|
|
|
|
snow_min = lib_materials.minheight_snow,
|
|
|
|
snow_max = lib_materials.maxheight_snow,
|
|
|
|
strato = lib_materials.maxheight_strato,
|
|
|
|
}
|
|
|
|
|
|
|
|
local temperatures = {
|
|
|
|
hot = lib_materials.temperature_hot,
|
|
|
|
warm = lib_materials.temperature_warm,
|
|
|
|
temperate = lib_materials.temperature_temperate,
|
|
|
|
cool = lib_materials.temperature_cool,
|
|
|
|
cold = lib_materials.temperature_cold,
|
|
|
|
}
|
|
|
|
|
|
|
|
local humidities = {
|
|
|
|
humid = lib_materials.humidity_humid,
|
|
|
|
semihumid = lib_materials.humidity_semihumid,
|
|
|
|
temperate = lib_materials.humidity_temperate,
|
|
|
|
semiarid = lib_materials.humidity_semiarid,
|
|
|
|
arid = lib_materials.humidity_arid,
|
|
|
|
}
|
|
|
|
|
|
|
|
local function read_node_str(node_str)
|
|
|
|
if #node_str > 0 then
|
|
|
|
local node, count = node_str:match("([^%s]+)%s*(%d*)")
|
|
|
|
return node, tonumber(count) or 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i, biome in ipairs(lib_materials.read_csv(",", lib_materials.path .. "/biomes.csv")) do
|
|
|
|
local a, b, c, d, e, f, g, h, i, j, k, l = unpack(biome)
|
|
|
|
--minetest.log(a .. ", " .. b .. ", " .. c .. ", " .. d .. ", " .. e .. ", " .. f .. ", " .. g .. ", " .. h .. ", " .. i .. ", " .. j .. ", " .. k .. ", " .. l)
|
|
|
|
|
|
|
|
-- Parse node names: transform empty strings into nil and separate node and count
|
|
|
|
b = read_node_str(b)
|
|
|
|
local c1, c2 = read_node_str(c)
|
|
|
|
local d1, d2 = read_node_str(d)
|
|
|
|
e = read_node_str(e)
|
|
|
|
local f1, f2 = read_node_str(f)
|
|
|
|
g = read_node_str(g)
|
|
|
|
h = read_node_str(h)
|
2019-04-17 18:16:36 +02:00
|
|
|
|
|
|
|
minetest.register_biome({
|
|
|
|
name = a,
|
|
|
|
node_dust = b,
|
2019-08-30 23:05:56 +02:00
|
|
|
node_top = c1,
|
|
|
|
depth_top = c2,
|
|
|
|
node_filler = d1,
|
|
|
|
depth_filler = d2,
|
|
|
|
node_stone = e,
|
|
|
|
node_water_top = f1,
|
|
|
|
depth_water_top = f2,
|
|
|
|
node_water = g,
|
|
|
|
node_river_water = h,
|
|
|
|
y_min = tonumber(i) or heights[i],
|
|
|
|
y_max = tonumber(j) or heights[j],
|
2019-04-17 18:16:36 +02:00
|
|
|
vertical_blend = lib_materials.biome_vertical_blend,
|
2019-08-30 23:05:56 +02:00
|
|
|
heat_point = tonumber(k) or temperatures[k],
|
|
|
|
humidity_point = tonumber(l) or humidities[l],
|
2019-04-17 18:16:36 +02:00
|
|
|
})
|
|
|
|
end
|