1
0
mirror of https://github.com/Gael-de-Sailly/30-biomes.git synced 2024-11-15 06:50:40 +01:00
30biomes/init.lua
Gael-de-Sailly d95ae22814 Use a CSV file for biome data.
Future modifications should be done using Calc, Excel or any other spreadsheet software.
I've chosen this format because it's a text format that is easily readable.
2016-04-05 14:30:18 +02:00

75 lines
2.0 KiB
Lua

local path = minetest.get_modpath("biomes")
minetest.clear_registered_biomes()
minetest.clear_registered_decorations()
minetest.register_node("biomes:mud", {
description = "Mud",
tiles = {"biomes_mud.png"},
liquid_viscosity = 8,
liquidtype = "source",
liquid_renewable = false,
liquid_alternative_source = "biomes:mud",
liquid_alternative_flowing = "biomes:mud",
liquid_range = 0,
post_effect_color = {r=115, g=61, b=31, a=255},
drowning = 1,
walkable = false,
groups = {crumbly = 2},
sounds = default.node_sound_dirt_defaults(),
})
for line in io.lines(path .. "/biomes.csv") do
local attribs = line:split(",", true)
local name, stone, fill, top, dust, sea, river, ymin, ymax, heat, humidity = unpack(attribs)
if #name > 0 and name:sub(1,1) ~= "#" then
-- Register biome
local biome = {name=name}
if stone and #stone > 0 then
biome.stone = stone
end
if fill and #fill > 0 then
fill = fill:split("%s", false, 1, true)
biome.node_filler = fill[1]
biome.depth_filler = tonumber(fill[2] or 1)
end
if top and #top > 0 then
top = top:split("%s", false, 1, true)
biome.node_top = top[1]
biome.depth_top = tonumber(top[2] or 1)
end
if dust and #dust > 0 then
biome.node_dust = dust
end
if sea and #sea > 0 then
sea = sea:split("%s", false, 1, true)
biome.node_water_top = sea[1]
biome.depth_water_top = tonumber(sea[2] or 1)
end
if river and #river > 0 then
biome.node_river_water = river
end
biome.y_min = tonumber(ymin) or -31000
biome.y_max = tonumber(ymax) or 31000
biome.heat_point = tonumber(heat) or 50
biome.humidity_point = tonumber(humidity) or 50
local id = minetest.register_biome(biome)
print("Biome \"" .. name .. "\" registered with ID=" .. id .. ", temperature " .. biome.heat_point .. ", humidity " .. biome.humidity_point .. ".")
end
end
--dofile(path .. "/main_biomes.lua")
--dofile(path .. "/beach_biomes.lua")
--dofile(path .. "/sea_biomes.lua")
dofile(path .. "/decorations.lua")