Updated to 1.2

master
Gael-de-Sailly 2014-09-22 20:17:30 +02:00
parent 7ffc34e957
commit cfd753c32e
105 changed files with 2666 additions and 4 deletions

View File

@ -1,3 +1,6 @@
default
fire
dye
bucket
stairs
flowers

10
fir.lua
View File

@ -2,7 +2,7 @@ function fir_growing(pos)
local height = math.random(5,13)
-- build the trunk
for dy = 0, height do
minetest.env:set_node({x = pos.x, y = pos.y + dy, z = pos.z}, {name = "forest:fir_tree"})
minetest.set_node({x = pos.x, y = pos.y + dy, z = pos.z}, {name = "forest:fir_tree"})
end
local steps = math.floor(height * 0.75 + 2.25)
local dist = 0
@ -17,8 +17,8 @@ function fir_growing(pos)
pos.y = pos.y + height + 3 - dy
pos.z = pos.z + dz
-- for each cell we will get 60% chance to have leaves
if (minetest.env:get_node(pos).name == "air" or minetest.env:get_node(pos).name == "ignore") and math.random(1, 5) <= 3 then
minetest.env:set_node(pos, {name = "forest:fir_leaves"})
if (minetest.get_node(pos).name == "air" or minetest.get_node(pos).name == "ignore") and math.random(1, 5) <= 3 then
minetest.set_node(pos, {name = "forest:fir_leaves"})
end
pos.x = pos.x - dx
pos.y = pos.y - height - 3 + dy
@ -26,7 +26,9 @@ function fir_growing(pos)
end
end
end
if minetest.get_node({x = pos.x, y = pos.y + height + 2, z = pos.z}).name == "forest:fir_leaves" and minetest.get_node({x = pos.x, y = pos.y + height + 1, z = pos.z}).name == "air" then
-- if the leaves node at the top is floating, put another leaves node under
local node_top = minetest.get_node({x = pos.x, y = pos.y + height + 1, z = pos.z}).name
if minetest.get_node({x = pos.x, y = pos.y + height + 2, z = pos.z}).name == "forest:fir_leaves" and (node_top == "air" or node_top == "ignore") then
minetest.set_node({x = pos.x, y = pos.y + height + 1, z = pos.z}, {name = "forest:fir_leaves"})
end
end

413
init.lua Normal file
View File

@ -0,0 +1,413 @@
trees = {}
apportionment = {}
ores = {}
seasons = {}
winterblock = {}
num_ore = 0
function distance(pos1, pos2)
return math.sqrt((pos1.x - pos2.x) ^ 2 + (pos1.y - pos2.y) ^ 2 + (pos1.z - pos2.z) ^ 2)
end
function get_instant_temperature(pos)
local temperature = minetest.get_perlin(554, 3, 0.6, 40)
local season = - math.cos(math.rad(math.mod(minetest.get_gametime(), 14400) / 40)) * 5
local time = - math.cos(math.rad(minetest.get_timeofday() * 360 - 45)) * 2
local value = temperature:get3d(pos) * 4 - pos.y * 0.16 + 16 + season + time
if value < 0 then
value = 0
elseif value > 20 then
value = 20
end
return value
end
function get_average_temperature(pos)
local temperature = minetest.get_perlin(554, 3, 0.6, 40)
local season = minetest.get_gametime()
local value = temperature:get3d(pos) * 4 - pos.y * 0.16 + 16
if value < 0 then
value = 0
elseif value > 20 then
value = 20
end
return value
end
function register_season(nodename, params)
-- the season params are from 1.00 (early January) to 12.99 (end of December). Convert it into number like this : 0 ≥ n > 12.
params.start = params.start - 1
params.stop = params.stop - 1
if params.type == "appear" then
if not winterblock[nodename] then
winterblock[nodename] = {}
end
table.insert(winterblock[nodename], params)
else
if not seasons[nodename] then
seasons[nodename] = {}
end
table.insert(seasons[nodename], params)
end
local paramnode = minetest.registered_nodes[nodename]
-- set the group "season"
if not paramnode.groups then
paramnode.groups = {}
end
paramnode.groups.season = 1
minetest.register_node(":"..nodename, paramnode)
end
minetest.register_node("forest:winterblock", {
description = "Bloc hiver",
drawtype = "airlike",
is_ground_content = true,
groups = {not_in_creative_inventory = 1},
paramtype = "light",
sunlight_propagates = true,
buildable_to = true,
pointable = false,
walkable = false,
})
minetest.register_abm({
nodenames = {"forest:winterblock"},
interval = 60,
chance = 1,
action = function(pos)
local meta = minetest.get_meta(pos)
local node = minetest.deserialize(meta:get_string("old_node"))
if not node then
minetest.dig_node(pos)
return
end
local superparams = winterblock[node.name]
for num, params in pairs(superparams) do
local time = math.mod(params.stop - params.start + 12, 12)
local season = math.mod(minetest.get_gametime(), 14400) / 1200
if math.random() * 100 < params.speed and math.mod(season - params.start + 12, 12) < time then
if minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name ~= "air" then
if params.new_node then
minetest.set_node(pos, params.new_node)
print("[forest] "..node.name.." reappear as "..params.new_node.name.." at "..minetest.pos_to_string(pos))
else
minetest.set_node(pos, node)
print("[forest] "..node.name.." reappear at "..minetest.pos_to_string(pos))
end
else
minetest.dig_node(pos)
end
end
end
end,
})
minetest.register_abm({
nodenames = {"group:season"},
interval = 60,
chance = 1,
action = function(pos, node)
local superparams = seasons[node.name]
for num, params in pairs(superparams) do
if math.random() * 100 < params.speed then
local time = math.mod(params.stop - params.start + 12, 12)
local season = math.mod(minetest.get_gametime(), 14400) / 1200
if math.mod(season - params.start + 12, 12) < time then
if params.type == "disappear" then
minetest.set_node(pos, {name = "forest:winterblock"})
print("[forest] "..node.name.." disappears at "..minetest.pos_to_string(pos))
local meta = minetest.get_meta(pos)
-- memorize the old node
if params.new_node then
meta:set_string("old_node", minetest.serialize(params.new_node))
else
meta:set_string("old_node", minetest.serialize(node))
end
elseif params.type == "transforms" then
minetest.set_node(pos, params.new_node)
print("[forest] "..node.name.." turn into "..params.new_node.name.." at "..minetest.pos_to_string(pos))
end
end
end
end
end,
})
function register_ore(def)
num_ore = num_ore + 1
ores[num_ore] = def
end
dofile(minetest.get_modpath("forest").."/tree_growing.lua")
dofile(minetest.get_modpath("forest").."/register_tree.lua")
dofile(minetest.get_modpath("forest").."/fir.lua")
dofile(minetest.get_modpath("forest").."/trees.lua")
dofile(minetest.get_modpath("forest").."/mud.lua")
dofile(minetest.get_modpath("forest").."/oil.lua")
dofile(minetest.get_modpath("forest").."/ores.lua")
dofile(minetest.get_modpath("forest").."/mapgen.lua")
dofile(minetest.get_modpath("forest").."/thermometer.lua")
dofile(minetest.get_modpath("forest").."/seasons.lua")
minetest.register_abm({
nodenames = {"default:dirt_with_grass", "default:dirt_with_snow"},
interval = 20,
chance = 3,
action = function(pos)
if get_instant_temperature(pos) + math.random() < 8 then
minetest.set_node(pos, {name = "default:dirt_with_snow"})
else
minetest.set_node(pos, {name = "default:dirt_with_grass"})
end
end,
})
minetest.register_abm({
nodenames = {"default:water_source", "default:ice"},
interval = 20,
chance = 3,
action = function(pos)
if get_instant_temperature(pos) + math.random() < 8 then
minetest.set_node(pos, {name = "default:ice"})
else
minetest.set_node(pos, {name = "default:water_source"})
end
end,
})
minetest.register_abm({
nodenames = {"forest:mud_source", "forest:mud_ice"},
interval = 20,
chance = 3,
action = function(pos)
if get_instant_temperature(pos) + math.random() < 8 then
minetest.set_node(pos, {name = "forest:mud_ice"})
else
minetest.set_node(pos, {name = "forest:mud_source"})
end
end,
})
-- I DETEST floating trees !
minetest.register_abm({
nodenames = {"group:tree"},
interval = 10,
chance = 1,
action = function(pos)
pos.y = pos.y - 1
if minetest.get_node(pos).name == "air" then
pos.y = pos.y + 1
minetest.dig_node(pos)
end
end,
})
minetest.register_node(":default:ice", {
description = "Ice",
drawtype = "glasslike",
tiles = {"new_ice.png"},
inventory_image = minetest.inventorycube("default_ice.png"),
is_ground_content = true,
paramtype = "light",
freezemelt = "default:water_source",
groups = {cracky=3, melts=1},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("forest:_clock", {
description = "Clock",
tiles = {"clock.png","default_wood.png","default_wood.png","default_wood.png","default_wood.png","default_wood.png"},
is_ground_content = true,
paramtype = "light",
groups = {dig_immediate=2},
on_construct = function(pos)
clockblock(pos)
end,
on_place = minetest.rotate_node
})
function clockblock(pos)
local season = math.floor(math.mod(minetest.get_gametime() + 600 - minetest.get_timeofday() * 1200, 14400) / 1200)
local month = nil
if season == 0 then
month = "Janvier"
elseif season == 1 then
month = "Fevrier"
elseif season == 2 then
month = "Mars"
elseif season == 3 then
month = "Avril"
elseif season == 4 then
month = "Mai"
elseif season == 5 then
month = "Juin"
elseif season == 6 then
month = "Juillet"
elseif season == 7 then
month = "Aout"
elseif season == 8 then
month = "Septembre"
elseif season == 9 then
month = "Octobre"
elseif season == 10 then
month = "Novembre"
elseif season == 11 then
month = "Decembre"
end
local year = math.floor((minetest.get_gametime() + 600 - minetest.get_timeofday() * 1200) / 14400)
local time = math.floor(minetest.get_timeofday() * 1440)
local hour = math.floor(time / 60)
local minute = math.mod(time, 60)
local meta = minetest.get_meta(pos)
local separator = nil
if minute < 10 then
separator = ":0"
else
separator = ":"
end
meta:set_string("infotext", month.." "..year..", "..hour..separator..minute)
end
minetest.register_abm({
nodenames = {"forest:_clock"},
interval = 2,
chance = 1,
action = function(pos)
clockblock(pos)
end,
})
minetest.register_craft({
output = 'forest:_clock',
recipe = {
{'group:wood', 'group:stick', 'group:wood'},
{'group:wood', 'default:mese_crystal', 'group:stick'},
{'group:wood', 'group:wood', 'group:wood'},
}
})
minetest.register_craft({
output = 'dye:black',
recipe = {
{'default:coal_lump'},
}
})
minetest.register_node("forest:sand_way", {
description = "Sand heap",
drawtype = "raillike",
tiles = {"sand_way.png", "sand_way_curved.png", "sand_way_t_junction.png", "sand_way_crossing.png"},
inventory_image = "sand_heap.png",
wield_image = "sand_heap.png",
paramtype = "light",
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = {dig_immediate=3,way=1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node("forest:gravel_way", {
description = "Gravel heap",
drawtype = "raillike",
tiles = {"gravel_way.png", "gravel_way_curved.png", "gravel_way_t_junction.png", "gravel_way_crossing.png"},
inventory_image = "gravel_heap.png",
wield_image = "gravel_heap.png",
paramtype = "light",
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = {dig_immediate=3,way=1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node("forest:desert_sand_way", {
description = "Desert sand heap",
drawtype = "raillike",
tiles = {"desert_sand_way.png", "desert_sand_way_curved.png", "desert_sand_way_t_junction.png", "desert_sand_way_crossing.png"},
inventory_image = "desert_sand_heap.png",
wield_image = "desert_sand_heap.png",
paramtype = "light",
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = {dig_immediate=3,way=1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_craft({
output = 'forest:sand_way 9',
recipe = {
{'default:sand'},
}
})
minetest.register_craft({
output = 'forest:gravel_way 9',
recipe = {
{'default:gravel'},
}
})
minetest.register_craft({
output = 'forest:desert_sand_way 9',
recipe = {
{'default:desert_sand'},
}
})
minetest.register_craft({
output = 'default:sand',
recipe = {
{'forest:sand_way', 'forest:sand_way', 'forest:sand_way'},
{'forest:sand_way', 'forest:sand_way', 'forest:sand_way'},
{'forest:sand_way', 'forest:sand_way', 'forest:sand_way'},
}
})
minetest.register_craft({
output = 'default:gravel',
recipe = {
{'forest:gravel_way', 'forest:gravel_way', 'forest:gravel_way'},
{'forest:gravel_way', 'forest:gravel_way', 'forest:gravel_way'},
{'forest:gravel_way', 'forest:gravel_way', 'forest:gravel_way'},
}
})
minetest.register_craft({
output = 'default:desert_sand',
recipe = {
{'forest:desert_sand_way', 'forest:desert_sand_way', 'forest:desert_sand_way'},
{'forest:desert_sand_way', 'forest:desert_sand_way', 'forest:desert_sand_way'},
{'forest:desert_sand_way', 'forest:desert_sand_way', 'forest:desert_sand_way'},
}
})
minetest.register_craft({
output = "moreblocks:circular_saw 1",
recipe = {
{ "", "default:steel_ingot", "" },
{ "group:tree", "group:tree", "group:tree"},
{ "group:tree", "", "group:tree"},
}
})
minetest.register_craft({
output = 'default:mese_crystal',
recipe = {
{'default:mese_crystal_fragment', 'default:mese_crystal_fragment', 'default:mese_crystal_fragment'},
{'default:mese_crystal_fragment', 'default:mese_crystal_fragment', 'default:mese_crystal_fragment'},
{'default:mese_crystal_fragment', 'default:mese_crystal_fragment', 'default:mese_crystal_fragment'},
}
})

597
mapgen.lua Normal file
View File

@ -0,0 +1,597 @@
-- 3D noises
local np_n1 = {
offset = 0,
scale = 1,
spread = {x=30, y=30, z=30},
seed = 5203,
octaves = 3,
persist = 0.6
}
local np_n2 = {
offset = 0,
scale = 1,
spread = {x=30, y=30, z=30},
seed = 7660,
octaves = 3,
persist = 0.6
}
local np_n3 = {
offset = 0,
scale = 1,
spread = {x=30, y=30, z=30},
seed = 3289,
octaves = 3,
persist = 0.6
}
local np_n4 = {
offset = 0,
scale = 1,
spread = {x=150, y=150, z=150},
seed = 5435,
octaves = 3,
persist = 0.6
}
-- 2D noises
local np_n5 = {
offset = 0,
scale = 1,
spread = {x=80, y=80, z=80},
seed = 9849,
octaves = 3,
persist = 0.6
}
local np_n6 = {
offset = 0,
scale = 1,
spread = {x=200, y=200, z=200},
seed = 7237,
octaves = 3,
persist = 0.6
}
local np_n7 = {
offset = 0,
scale = 1,
spread = {x=600, y=600, z=600},
seed = 5096,
octaves = 3,
persist = 0.6
}
local np_n8 = {
offset = 0,
scale = 1,
spread = {x=20, y=20, z=20},
seed = 7230,
octaves = 3,
persist = 0.6
}
local np_n9 = {
offset = 0,
scale = 1,
spread = {x=20, y=20, z=20},
seed = 9933,
octaves = 3,
persist = 0.6
}
-- elevation noises
local np_n1e = {
offset = 0,
scale = 1,
spread = {x=50, y=50, z=50},
seed = 6831,
octaves = 3,
persist = 0.2
}
local np_n2e = {
offset = 0,
scale = 1,
spread = {x=50, y=50, z=50},
seed = 1590,
octaves = 3,
persist = 0.2
}
local np_n3e = {
offset = 0,
scale = 1,
spread = {x=25, y=25, z=25},
seed = 4385,
octaves = 3,
persist = 0.2
}
local np_n4e = {
offset = 0,
scale = 1,
spread = {x=25, y=25, z=25},
seed = 9726,
octaves = 3,
persist = 0.2
}
local np_n5e = {
offset = 0,
scale = 1,
spread = {x=10, y=10, z=10},
seed = 1792,
octaves = 3,
persist = 0.2
}
local np_n6e = {
offset = 0,
scale = 1,
spread = {x=10, y=10, z=10},
seed = 1016,
octaves = 3,
persist = 0.2
}
local np_n7e = {
offset = 0,
scale = 1,
spread = {x=300, y=300, z=300},
seed = 8110,
octaves = 3,
persist = 0.2
}
local np_n8e = {
offset = 0,
scale = 1,
spread = {x=400, y=400, z=400},
seed = 2698,
octaves = 3,
persist = 0.2
}
-- elevation function for spawnplayer
function get_elevation(pos)
local pos2d = {x = pos.x, y = pos.z}
local n1 = minetest.get_perlin(6831, 3, 0.2, 50):get2d(pos2d)
local n2 = minetest.get_perlin(1590, 3, 0.2, 50):get2d(pos2d)
local n3 = minetest.get_perlin(4385, 3, 0.2, 25):get2d(pos2d)
local n4 = minetest.get_perlin(9726, 3, 0.2, 25):get2d(pos2d)
local n5 = minetest.get_perlin(1792, 3, 0.2, 10):get2d(pos2d)
local n6 = minetest.get_perlin(1016, 3, 0.2, 10):get2d(pos2d)
local n7 = minetest.get_perlin(8110, 3, 0.2, 300):get2d(pos2d)
local n8 = minetest.get_perlin(2698, 3, 0.2, 400):get2d(pos2d)
local value1 = math.abs(n1 - n2) * math.abs(n7)
local value2 = math.sqrt(value1 * math.abs(n3 - n4)) * math.abs(n7)
local value3 = math.sqrt(value2 * math.abs(n5 - n6)) * math.abs(n7)
value1 = value1 + value1 * n8
value2 = value2 + value2 * n8
value3 = value3 + value3 * n8
local value = value1 * 20 + value2 * 15 + value3 * 10 + n8 * 50
if value < 0 then
value = -2 * math.sqrt(-value)
end
return math.floor(value + 0.5)
end
-- Set mapgen parameters
minetest.register_on_mapgen_init(function(mgparams)
minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"})
end)
------------------------ Base map generation ------------------------
minetest.register_on_generated(function(minp, maxp)
local t0 = os.clock()
local x1 = maxp.x
local y1 = maxp.y
local z1 = maxp.z
local x0 = minp.x
local y0 = minp.y
local z0 = minp.z
print ("[forest] Generating map from "..minetest.pos_to_string(minp).." to "..minetest.pos_to_string(maxp))
local c_dstone = minetest.get_content_id("default:desert_stone")
local c_dsand = minetest.get_content_id("default:desert_sand")
local c_water = minetest.get_content_id("default:water_source")
local c_stone = minetest.get_content_id("default:stone")
local c_sand = minetest.get_content_id("default:sand")
local c_grass = minetest.get_content_id("default:dirt_with_grass")
local c_snow = minetest.get_content_id("default:dirt_with_snow")
local c_dirt = minetest.get_content_id("default:dirt")
local c_gravel = minetest.get_content_id("default:gravel")
local c_grasses = {
minetest.get_content_id("default:grass_1"),
minetest.get_content_id("default:grass_2"),
minetest.get_content_id("default:grass_3"),
minetest.get_content_id("default:grass_4"),
minetest.get_content_id("default:grass_5")
}
local c_jungle = minetest.get_content_id("default:junglegrass")
local c_flowers = {minetest.get_content_id("flowers:dandelion_yellow"), minetest.get_content_id("flowers:dandelion_yellow"), minetest.get_content_id("flowers:dandelion_yellow"), minetest.get_content_id("flowers:geranium"), minetest.get_content_id("flowers:tulip"), minetest.get_content_id("flowers:rose")}
local c_papyrus = minetest.get_content_id("default:papyrus")
local c_shrub = minetest.get_content_id("default:dry_shrub")
local c_lava = minetest.get_content_id("default:lava_source")
local c_cactus = minetest.get_content_id("default:cactus")
local c_ignore = minetest.get_content_id("ignore")
local c_air = minetest.get_content_id("air")
-- LVM stuff
local manip, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local data = manip:get_data()
local elevation
local node
local pos
local ground1, ground2, ground3, ground4, plant
-- perlinmap stuff
local sidelen = x1 - x0 + 1
local chulens = {x=sidelen, y=sidelen, z=sidelen}
local minposxyz = {x=x0, y=y0, z=z0}
local minposxz = {x=x0, y=z0}
-- 3D noises
local nvals_n1 = minetest.get_perlin_map(np_n1, chulens):get3dMap_flat(minposxyz)
local nvals_n2 = minetest.get_perlin_map(np_n2, chulens):get3dMap_flat(minposxyz)
local nvals_n3 = minetest.get_perlin_map(np_n3, chulens):get3dMap_flat(minposxyz)
local nvals_n4 = minetest.get_perlin_map(np_n4, chulens):get3dMap_flat(minposxyz)
-- 2D noises
local nvals_n5 = minetest.get_perlin_map(np_n5, chulens):get2dMap_flat(minposxz)
local nvals_n6 = minetest.get_perlin_map(np_n6, chulens):get2dMap_flat(minposxz)
local nvals_n7 = minetest.get_perlin_map(np_n7, chulens):get2dMap_flat(minposxz)
local nvals_n8 = minetest.get_perlin_map(np_n8, chulens):get2dMap_flat(minposxz)
local nvals_n9 = minetest.get_perlin_map(np_n9, chulens):get2dMap_flat(minposxz)
-- elevation 2D noises
local nvals_n1e = minetest.get_perlin_map(np_n1e, chulens):get2dMap_flat(minposxz)
local nvals_n2e = minetest.get_perlin_map(np_n2e, chulens):get2dMap_flat(minposxz)
local nvals_n3e = minetest.get_perlin_map(np_n3e, chulens):get2dMap_flat(minposxz)
local nvals_n4e = minetest.get_perlin_map(np_n4e, chulens):get2dMap_flat(minposxz)
local nvals_n5e = minetest.get_perlin_map(np_n5e, chulens):get2dMap_flat(minposxz)
local nvals_n6e = minetest.get_perlin_map(np_n6e, chulens):get2dMap_flat(minposxz)
local nvals_n7e = minetest.get_perlin_map(np_n7e, chulens):get2dMap_flat(minposxz)
local nvals_n8e = minetest.get_perlin_map(np_n8e, chulens):get2dMap_flat(minposxz)
local nixz = 1 -- 2D noise index
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local n1 = nvals_n1e[nixz]
local n2 = nvals_n2e[nixz]
local n3 = nvals_n3e[nixz]
local n4 = nvals_n4e[nixz]
local n5 = nvals_n5e[nixz]
local n6 = nvals_n6e[nixz]
local n7 = nvals_n7e[nixz]
local n8 = nvals_n8e[nixz]
local value1 = math.abs(n1 - n2) * math.abs(n7)
local value2 = math.sqrt(value1 * math.abs(n3 - n4)) * math.abs(n7)
local value3 = math.sqrt(value2 * math.abs(n5 - n6)) * math.abs(n7)
value1 = value1 + value1 * n8
value2 = value2 + value2 * n8
value3 = value3 + value3 * n8
local value = value1 * 20 + value2 * 15 + value3 * 10 + n8 * 50
if value < 0 then
value = -2 * math.sqrt(-value)
end
elevation = math.floor(value + 0.5)
if math.max(elevation, 1) >= minp.y then
n5v = nvals_n5[nixz]
n6v = nvals_n6[nixz]
n7v = nvals_n7[nixz]
n8v = nvals_n8[nixz]
n9v = nvals_n9[nixz]
if elevation < n8v * 5 then
if n7v < 0.88 then
if n5v - n6v > 0.8 then
ground1 = c_gravel
ground2 = c_gravel
ground3 = c_stone
ground4 = c_stone
plant = nil
elseif n6v < 0 then
if n5v < -0.4 then
ground1 = c_dsand
ground2 = c_dsand
ground3 = c_dstone
ground4 = c_stone
plant = nil
else
ground1 = c_sand
ground2 = c_sand
ground3 = c_stone
ground4 = c_stone
plant = nil
end
elseif n5v + n6v * 5 > 2 then
if n6v > 0.8 then
ground1 = c_gravel
ground2 = c_gravel
ground3 = c_stone
ground4 = c_stone
plant = nil
else
ground1 = c_grass
ground2 = c_dirt
ground3 = c_stone
ground4 = c_stone
plant = {def = c_papyrus, percent = 4, height = math.random(2, 5)}
end
else
ground1 = c_sand
ground2 = c_sand
ground3 = c_stone
ground4 = c_stone
plant = {def = c_grasses[math.random(5)], percent = 15}
end
elseif n5v * 2 - n6v < 0 then
ground1 = c_gravel
ground2 = c_gravel
ground3 = c_stone
ground4 = c_stone
plant = nil
else
ground1 = c_stone
ground2 = c_stone
ground3 = c_stone
ground4 = c_stone
plant = nil
end
elseif n7v < 0.88 then
if n5v + 2 * n6v > -0.4 then
if n5v > 0 then
ground1 = c_grass
ground2 = c_dirt
ground3 = c_stone
ground4 = c_stone
plant = nil
else
ground1 = c_grass
ground2 = c_dirt
ground3 = c_stone
ground4 = c_stone
if math.random(2) == 2 then
plant = {def = c_grasses[math.random(5)], percent = 20}
else
plant = {def = c_flowers[math.random(6)], percent = -n5v}
end
end
elseif n6v < -0.4 then
ground1 = c_dsand
ground2 = c_dsand
ground3 = c_dstone
ground4 = c_stone
if math.random(2) == 2 then
plant = {def = c_cactus, percent = 2, height = math.random(2, 6)}
else
plant = {def = c_shrub, percent = 5}
end
else
ground1 = c_sand
ground2 = c_sand
ground3 = c_dstone
ground4 = c_stone
if math.random(2) == 2 then
plant = {def = c_cactus, percent = 0.25, height = math.random(2, 4)}
else
plant = {def = c_jungle, percent = 25}
end
end
elseif n5v ^ 2 + n6v ^ 2 < 0.16 and n7v > 0.9 then
ground1 = c_air
ground2 = c_lava
ground3 = c_stone
ground4 = c_stone
plant = nil
elevation = math.min(
elevation, get_elevation({x = x, z = z + 1}),
get_elevation({x = x, z = z - 1}),
get_elevation({x = x + 1, z = z}),
get_elevation({x = x - 1, z = z})
)
elseif n5v > -0.6 then
ground1 = c_stone
ground2 = c_stone
ground3 = c_stone
ground4 = c_stone
plant = nil
else
ground1 = c_gravel
ground2 = c_gravel
ground3 = c_stone
ground4 = c_stone
plant = nil
end
for y = minp.y, math.min(math.max(elevation, 1), maxp.y) do
pos = area:index(x, y, z) -- LVM index for node
local nixyz = (z - z0) * 6400 + (y - y0) * 80 + (x - x0) + 1 -- noise index for node
n1v = nvals_n1[nixyz]
n2v = nvals_n2[nixyz]
n3v = nvals_n3[nixyz]
n4v = nvals_n4[nixyz]
if y == elevation then
if elevation >= 1 then
node = ground1
else
node = ground2
end
elseif y > elevation then
node = c_water
elseif y + math.random(2, 6) >= elevation then
node = ground2
elseif y + 20 + n9v * 10 >= elevation then
node = ground3
else
node = ground4
end
if math.max(n1v, n2v, n3v) - math.min(n1v, n2v, n3v) > n4v / 5 or node == c_water then
data[pos] = node
end
end
if elevation > 0 and plant then
if math.random() * 100 < plant.percent then
if plant.height then
for i = 1, plant.height do
if area:contains(x, elevation + i, z) then
data[area:index(x, elevation + i, z)] = plant.def
end
end
elseif area:contains(x, elevation + 1, z) then
data[area:index(x, elevation + 1, z)] = plant.def
end
end
end
end
nixz = nixz + 1 -- increment 2D noise index
end
end
manip:set_data(data)
manip:update_liquids()
manip:calc_lighting()
manip:write_to_map(data)
------------------------ Ore generation ------------------------
local t1 = os.clock()
local pr = PseudoRandom(math.random(1000))
for num, def in pairs(ores) do
local noise = minetest.get_perlin(def.seed, 1, 0, def.scale)
if def.gradiant then
for i = 1, def.frequency do
local middle = {x = pr:next(minp.x, maxp.x), y = pr:next(minp.y, maxp.y), z = pr:next(minp.z, maxp.z)}
if noise:get3d(middle) + math.random() * 2 >= 1 and middle.y < def.max_y and middle.y > def.min_y then
local zone = minetest.find_nodes_in_area(
{x = middle.x - def.radius, y = middle.y - def.radius, z = middle.z - def.radius},
{x = middle.x + def.radius, y = middle.y + def.radius, z = middle.z + def.radius},
{def.wherein}
)
for node, pos in pairs(zone) do
if distance(middle, pos) / (def.radius + 1) - math.random() <= 0 and math.random(100) <= def.density then
minetest.set_node(pos, {name = def.ore})
end
end
end
if def.center then
minetest.set_node(middle, {name = def.center})
end
end
else
for i = 1, def.frequency do
local middle = {x = pr:next(minp.x, maxp.x), y = pr:next(minp.y, maxp.y), z = pr:next(minp.z, maxp.z)}
if noise:get3d(middle) + math.random() * 2 >= 1 and middle.y < def.max_y and middle.y > def.min_y then
local zone = minetest.find_nodes_in_area(
{x = middle.x - def.radius, y = middle.y - def.radius, z = middle.z - def.radius},
{x = middle.x + def.radius, y = middle.y + def.radius, z = middle.z + def.radius},
{def.wherein}
)
for node, pos in pairs(zone) do
if distance(middle, pos) <= def.radius and math.random(100) >= def.density then
minetest.set_node(pos, {name = def.ore})
end
end
end
end
end
end
------------------------ Tree generation ------------------------
local t2 = os.clock()
local biomes = minetest.get_perlin(289, 3, 0.6, 200)
local grass_area = minetest.find_nodes_in_area(minp, maxp, "default:dirt_with_grass")
for grass, pos in pairs(grass_area) do
if math.random(12) == math.random(12) then
local total = 0
local temperature = get_average_temperature(pos)
local biome = biomes:get3d(pos) * 50 + 50
local candidates = {}
local water = true
local list = ""
for specie, def in pairs(apportionment) do
local difference = (def.biome - biome) ^ 2
if def.water_proximity then
if minetest.find_node_near(pos, math.abs(def.water_proximity), {"group:water"}) == nil then
water = def.water_proximity <= 0
else
water = def.water_proximity >= 0
end
else
water = true
end
if temperature <= def.temperature.max and temperature >= def.temperature.min and water then
if difference < def.tolerance ^ 2 then
local chance = def.frequency * (1 - difference / def.tolerance ^ 2)
total = total + chance
candidates[specie] = total
end
end
end
local num = math.random() * total
local min = total
local tree = nil
for specie, num_chance in pairs(candidates) do
if num <= num_chance and num_chance <= min then
tree = specie
min = num_chance
end
end
local def = apportionment[tree]
pos = {x = pos.x, y = pos.y + 1, z = pos.z}
if def then
if math.random(20) <= def.density then
trees[tree].method(pos, tree)
end
end
end
end
local t3 = os.clock()
local chugent1 = math.ceil((t1 - t0) * 1000) / 1000
local chugent2 = math.ceil((t2 - t1) * 1000) / 1000
local chugent3 = math.ceil((t3 - t2) * 1000) / 1000
print ("[forest] Base map "..chugent1.." sec, Ores "..chugent2.." sec, Trees "..chugent3.." sec. Total "..chugent1 + chugent2 + chugent3.." sec.")
end)
function spawn_player(player)
local pr = PseudoRandom(math.random(1000000))
local pos = {x = pr:next(-250, 250), z = pr:next(-250, 250)}
local elevation = get_elevation(pos)
local dir
local noise = minetest.get_perlin(5096, 3, 0.6, 600)
while elevation < 2 and noise:get2d({x = pos.x, y = pos.z}) <= 0.85 do
dir = pr:next(1, 4)
if dir == 1 then
pos = {x = pos.x + 1, z = pos.z}
elseif dir == 2 then
pos = {x = pos.x - 1, z = pos.z}
elseif dir == 3 then
pos = {x = pos.x, z = pos.z + 1}
elseif dir == 4 then
pos = {x = pos.x, z = pos.z - 1}
end
elevation = get_elevation(pos)
end
pos = {x = pos.x, y = elevation + 2, z = pos.z}
player:setpos(pos)
end
minetest.register_on_newplayer(function(player)
spawn_player(player)
end)
minetest.register_on_respawnplayer(function(player)
spawn_player(player)
return true
end)

88
mud.lua Normal file
View File

@ -0,0 +1,88 @@
minetest.register_node("forest:mud_flowing", {
description = "Mud flowing",
inventory_image = minetest.inventorycube("mud.png"),
drawtype = "flowingliquid",
tiles = {"mud.png"},
special_tiles = {
{
image="mud_animated.png",
backface_culling=false,
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=4}
},
{
image="mud_animated.png",
backface_culling=true,
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=4}
},
},
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "forest:mud_flowing",
liquid_alternative_source = "forest:mud_source",
liquid_viscosity = 6,
freezemelt = "default:snow",
post_effect_color = {a=224, r=112, g=64, b=32},
groups = {liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1, water=1},
})
minetest.register_node("forest:mud_source", {
description = "Mud source",
inventory_image = minetest.inventorycube("mud.png"),
drawtype = "liquid",
tiles = {
{name="mud_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=9}}
},
special_tiles = {
{
name="mud_animated.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=9},
backface_culling = false,
}
},
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "forest:mud_flowing",
liquid_alternative_source = "forest:mud_source",
liquid_viscosity = 6,
freezemelt = "default:ice",
post_effect_color = {a=64, r=100, g=100, b=200},
groups = {liquid=3, puts_out_fire=1, freezes=1, water=1},
})
minetest.register_node("forest:mud_ice", {
description = "Mud ice",
drawtype = "glasslike",
tiles = {"mud.png^new_ice.png"},
is_ground_content = true,
paramtype = "light",
freezemelt = "default:mud_source",
groups = {cracky=3, melts=1},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft({
type = "shapeless",
output = "forest:bucket_mud",
recipe = {"bucket:bucket_water", "default:dirt"},
})
bucket.register_liquid(
"forest:mud_source",
"forest:mud_flowing",
"forest:bucket_mud",
"bucket_mud.png",
"Mud bucket"
)

82
oil.lua Normal file
View File

@ -0,0 +1,82 @@
minetest.register_node("forest:oil_flowing", {
description = "Oil flowing",
inventory_image = minetest.inventorycube("oil.png"),
drawtype = "flowingliquid",
tiles = {"oil.png"},
special_tiles = {
{
image="oil_flowing_animated.png",
backface_culling=false,
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=10}
},
{
image="oil_flowing_animated.png",
backface_culling=true,
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=10}
},
},
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "forest:oil_flowing",
liquid_alternative_source = "forest:oil_source",
liquid_viscosity = 4,
damage_per_second = 1,
post_effect_color = {a=255, r=32, g=20, b=12},
groups = {liquid=3, flammable=2, not_in_creative_inventory=1, oil=1},
})
minetest.register_node("forest:oil_source", {
description = "Oil source",
inventory_image = minetest.inventorycube("oil.png"),
drawtype = "liquid",
tiles = {
{name="oil_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=22}}
},
special_tiles = {
{
name="oil_source_animated.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=22},
backface_culling = false,
}
},
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "forest:oil_flowing",
liquid_alternative_source = "forest:oil_source",
liquid_viscosity = 4,
damage_per_second = 1,
post_effect_color = {a=255, r=32, g=20, b=12},
groups = {liquid=3, flammable=2, oil=1},
})
minetest.register_abm({
nodenames = {"group:oil"},
neighbors = {"group:igniter"},
chance = 10,
interval = 2,
action = function(pos)
minetest.set_node(pos, {name = "fire:basic_flame"})
minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25})
end,
})
bucket.register_liquid(
"forest:oil_source",
"forest:oil_flowing",
"forest:bucket_oil",
"bucket_oil.png",
"Oil bucket"
)

602
ores.lua Normal file
View File

@ -0,0 +1,602 @@
minetest.register_node("forest:_stone_with_coal", {
description = "Coal ore in desert stone",
tiles = {"default_desert_stone.png^default_mineral_coal.png"},
is_ground_content = true,
groups = {cracky=3},
drop = 'default:coal_lump',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("forest:_stone_with_iron", {
description = "Iron ore in desert stone",
tiles = {"default_desert_stone.png^default_mineral_iron.png"},
is_ground_content = true,
groups = {cracky=2},
drop = 'default:iron_lump',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("forest:_stone_with_copper", {
description = "Copper ore in desert stone",
tiles = {"default_desert_stone.png^default_mineral_copper.png"},
is_ground_content = true,
groups = {cracky=2},
drop = 'default:copper_lump',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("forest:_stone_with_gold", {
description = "Gold ore in desert stone",
tiles = {"default_desert_stone.png^default_mineral_gold.png"},
is_ground_content = true,
groups = {cracky=2},
drop = 'default:gold_lump',
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("forest:_stone_with_mese", {
description = "Mese ore in desert stone",
tiles = {"default_desert_stone.png^default_mineral_mese.png"},
is_ground_content = true,
groups = {cracky=2},
drop = {
max_items = 1,
items = {
{items = {"default:mese_crystal"}, rarity = 8},
{items = {"default:mese_crystal_fragment 8"}, rarity = 4},
{items = {"default:mese_crystal_fragment 7"}, rarity = 2},
{items = {"default:mese_crystal_fragment 6"}},
}
},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("forest:_gravel_with_coal", {
description = "Coal ore in gravel",
tiles = {"default_gravel.png^default_mineral_coal.png"},
is_ground_content = true,
groups = {crumbly=2, falling_node=1},
drop = 'default:coal_lump',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_node("forest:_gravel_with_iron", {
description = "Iron ore in gravel",
tiles = {"default_gravel.png^default_mineral_iron.png"},
is_ground_content = true,
groups = {crumbly=1, falling_node=1},
drop = 'default:iron_lump',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_node("forest:_gravel_with_gold", {
description = "Gold ore in gravel",
tiles = {"default_gravel.png^default_mineral_gold.png"},
is_ground_content = true,
groups = {crumbly=1, falling_node=1},
drop = 'default:gold_lump',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_node("forest:_gravel_with_copper", {
description = "Copper ore in gravel",
tiles = {"default_gravel.png^default_mineral_copper.png"},
is_ground_content = true,
groups = {crumbly=1, falling_node=1},
drop = 'default:copper_lump',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_node("forest:_gravel_with_diamond", {
description = "Diamond ore in gravel",
tiles = {"default_gravel.png^default_mineral_diamond.png"},
is_ground_content = true,
groups = {crumbly=1, falling_node=1},
drop = 'default:diamond',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
minetest.register_node("forest:_gravel_with_mese", {
description = "Mese ore in gravel",
tiles = {"default_gravel.png^default_mineral_mese.png"},
is_ground_content = true,
groups = {crumbly=1, falling_node=1},
drop = {
max_items = 5,
items = {
{items = {"default:mese_crystal_fragment 2"}},
{items = {"default:mese_crystal_fragment"}, rarity = 3},
{items = {"default:mese_crystal_fragment"}, rarity = 3},
{items = {"default:mese_crystal_fragment"}, rarity = 3},
},
},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.5},
dug = {name="default_gravel_footstep", gain=1.0},
}),
})
register_ore({
ore = "default:water_source",
wherein = "default:stone",
frequency = 40,
radius = 3,
density = 10,
gradiant = false,
min_y = -80,
max_y = 10,
seed = 9945,
scale = 100,
})
register_ore({
ore = "forest:oil_source",
wherein = "default:stone",
frequency = 80,
radius = 4,
density = 400,
gradiant = true,
min_y = -200,
max_y = -120,
seed = 1692,
scale = 100,
})
register_ore({
ore = "default:lava_source",
wherein = "default:stone",
frequency = 2,
radius = 12,
density = 200,
gradiant = true,
min_y = -31000,
max_y = -50,
seed = 7787,
scale = 100,
})
register_ore({
ore = "default:lava_source",
wherein = "default:stone",
frequency = 4,
radius = 8,
density = 200,
gradiant = true,
min_y = -31000,
max_y = -25,
seed = 7787,
scale = 100,
})
register_ore({
ore = "default:lava_source",
wherein = "default:stone",
frequency = 5,
radius = 4,
density = 200,
gradiant = true,
min_y = -31000,
max_y = -10,
seed = 7787,
scale = 100,
})
register_ore({
ore = "default:gravel",
wherein = "default:stone",
frequency = 10,
radius = 15,
density = 100,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 6430,
scale = 100,
})
register_ore({
ore = "default:stone_with_coal",
wherein = "default:stone",
frequency = 1000,
radius = 1,
density = 50,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 6808,
scale = 100,
})
register_ore({
ore = "default:stone_with_coal",
wherein = "default:stone",
frequency = 1000,
radius = 1,
density = 50,
gradiant = true,
min_y = -31000,
max_y = -20,
seed = 6808,
scale = 100,
})
register_ore({
ore = "default:stone_with_coal",
wherein = "default:stone",
frequency = 400,
radius = 4,
density = 50,
gradiant = true,
min_y = -100,
max_y = -40,
seed = 6808,
scale = 100,
})
register_ore({
ore = "forest:_stone_with_coal",
wherein = "default:desert_stone",
frequency = 600,
radius = 2,
density = 40,
gradiant = true,
min_y = -31000,
max_y = 0,
seed = 6808,
scale = 100,
})
register_ore({
ore = "forest:_stone_with_coal",
wherein = "default:desert_stone",
frequency = 200,
radius = 3,
density = 30,
gradiant = true,
min_y = -15,
max_y = 100,
seed = 6808,
scale = 100,
})
register_ore({
ore = "forest:_gravel_with_coal",
wherein = "default:gravel",
frequency = 300,
radius = 1,
density = 35,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 6808,
scale = 100,
})
register_ore({
ore = "default:stone_with_iron",
wherein = "default:stone",
frequency = 400,
radius = 1,
density = 80,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 2491,
scale = 100,
})
register_ore({
ore = "default:stone_with_iron",
wherein = "default:stone",
frequency = 300,
radius = 2,
density = 90,
gradiant = true,
min_y = -1000,
max_y = -60,
seed = 2491,
scale = 100,
})
register_ore({
ore = "default:stone_with_iron",
wherein = "default:stone",
frequency = 100,
radius = 3,
density = 70,
gradiant = true,
min_y = -150,
max_y = -10,
seed = 2491,
scale = 100,
})
register_ore({
ore = "forest:_stone_with_iron",
wherein = "default:desert_stone",
frequency = 400,
radius = 1,
density = 40,
gradiant = true,
min_y = -100,
max_y = 31000,
seed = 2491,
scale = 100,
})
register_ore({
ore = "forest:_stone_with_iron",
wherein = "default:desert_stone",
frequency = 50,
radius = 4,
density = 60,
gradiant = true,
min_y = 100,
max_y = 31000,
seed = 2491,
scale = 100,
})
register_ore({
ore = "forest:_gravel_with_iron",
wherein = "default:gravel",
frequency = 2000,
radius = 1,
density = 70,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 2491,
scale = 100,
})
register_ore({
ore = "default:stone_with_copper",
wherein = "default:stone",
frequency = 350,
radius = 1,
density = 50,
gradiant = false,
min_y = -31000,
max_y = -10,
seed = 1285,
scale = 100,
})
register_ore({
ore = "default:stone_with_copper",
wherein = "default:stone",
frequency = 100,
radius = 3,
density = 90,
gradiant = false,
min_y = -31000,
max_y = -80,
seed = 1285,
scale = 100,
})
register_ore({
ore = "default:stone_with_copper",
wherein = "default:stone",
frequency = 25,
radius = 1,
density = 50,
gradiant = false,
min_y = -31000,
max_y = -31000,
seed = 1285,
scale = 100,
})
register_ore({
ore = "default:stone_with_mese",
wherein = "default:stone",
frequency = 120,
radius = 1,
density = 30,
gradiant = true,
min_y = -31000,
max_y = -70,
seed = 2451,
scale = 100,
})
register_ore({
ore = "default:stone_with_mese",
wherein = "default:stone",
frequency = 40,
radius = 3,
density = 50,
gradiant = true,
min_y = -31000,
max_y = -200,
seed = 2451,
scale = 100,
})
register_ore({
ore = "default:stone_with_mese",
wherein = "default:stone",
frequency = 5,
radius = 2,
density = 20,
gradiant = true,
min_y = -31000,
max_y = -31000,
seed = 2451,
scale = 100,
})
register_ore({
ore = "forest:_stone_with_mese",
wherein = "default:desert_stone",
frequency = 30,
radius = 1,
density = 25,
gradiant = true,
min_y = -31000,
max_y = 31000,
seed = 2451,
scale = 100,
})
register_ore({
ore = "forest:_gravel_with_mese",
wherein = "default:gravel",
frequency = 40,
radius = 1,
density = 20,
gradiant = false,
min_y = -31000,
max_y = 31000,
seed = 2451,
scale = 100,
})
register_ore({
ore = "default:stone_with_diamond",
wherein = "default:stone",
frequency = 80,
radius = 1,
density = 20,
gradiant = false,
min_y = -31000,
max_y = -40,
seed = 287,
scale = 100,
})
register_ore({
ore = "default:stone_with_diamond",
wherein = "default:stone",
frequency = 100,
radius = 2,
density = 40,
gradiant = true,
min_y = -31000,
max_y = -180,
seed = 287,
scale = 100,
})
register_ore({
ore = "forest:_gravel_with_diamond",
wherein = "default:gravel",
frequency = 10,
radius = 1,
density = 20,
gradiant = false,
min_y = -31000,
max_y = 0,
seed = 287,
scale = 100,
})
register_ore({
ore = "default:mese",
wherein = "default:stone_with_mese",
frequency = 200,
radius = 5,
density = 100,
gradiant = false,
min_y = -31000,
max_y = -300,
seed = 1322,
scale = 100,
})
register_ore({
ore = "default:clay",
wherein = "default:sand",
frequency = 100,
radius = 5,
density = 100,
gradiant = true,
min_y = -40,
max_y = 20,
seed = 6975,
scale = 100,
})
register_ore({
ore = "forest:mud_source",
wherein = "default:dirt",
frequency = 80,
radius = 2,
density = 100,
gradiant = true,
min_y = 0,
max_y = 20,
seed = 2752,
scale = 100,
})
register_ore({
ore = "forest:mud_source",
wherein = "default:dirt",
frequency = 30,
radius = 2,
density = 100,
gradiant = true,
min_y = -12,
max_y = 70,
seed = 2752,
scale = 100,
})
register_ore({
ore = "default:sandstone",
wherein = "default:sand",
frequency = 200,
radius = 3,
density = 50,
gradiant = true,
min_y = -20,
max_y = 90,
seed = 4209,
scale = 100,
})
register_ore({
ore = "default:nyancat_rainbow",
--center = "default:nyancat",
wherein = "default:stone",
frequency = 1,
radius = 2,
density = 50,
gradiant = true,
min_y = -20,
max_y = 90,
seed = 4209,
scale = 100,
})
register_ore({
ore = "default:nyancat",
--center = "default:nyancat",
wherein = "default:lava_source",
frequency = 1,
radius = 0,
density = 100,
gradiant = false,
min_y = -31000,
max_y = 31000,
seed = 4209,
scale = 100,
})

259
register_tree.lua Normal file
View File

@ -0,0 +1,259 @@
function register_tree(specie, def)
if not def.description then
def.description = specie
end
if not def.descriptions then
def.descriptions = {}
end
if not def.descriptions.tree then
def.descriptions.tree = def.description.." tree"
end
if not def.descriptions.leaves then
def.descriptions.leaves = def.description.." leaves"
end
if not def.descriptions.wood then
def.descriptions.wood = def.description.." wood"
end
if not def.descriptions.sapling then
def.descriptions.sapling = def.description.." sapling"
end
if not def.descriptions.fruitleaves then
def.descriptions.fruitleaves = def.description.." fruitleaves"
end
if not def.descriptions.fruit then
def.descriptions.fruit = def.description.." fruit"
end
if not def.descriptions.stair then
def.descriptions.stair = def.description.." stair"
end
if not def.descriptions.slab then
def.descriptions.slab = def.description.." slab"
end
if not def.apportionment then
def.apportionment = {}
end
if not def.tiles then
def.tiles = {}
end
if not def.tiles.tree then
def.tiles.tree = specie.."_tree.png"
end
if not def.tiles.tree_top then
def.tiles.tree_top = specie.."_tree_top.png"
end
if not def.tiles.leaves then
def.tiles.leaves = specie.."_leaves.png"
end
if not def.tiles.sapling then
def.tiles.sapling = specie.."_sapling.png"
end
if not def.tiles.wood then
def.tiles.wood = specie.."_wood.png"
end
if not def.tiles.fruitleaves then
def.tiles.fruitleaves = specie.."_fruitleaves.png"
end
if not def.tiles.fruit then
def.tiles.fruit = specie.."_fruit.png"
end
if not def.growing.method then
def.growing.method = tree_growing
end
if not def.register then
def.register = {tree = true, leaves = true, sapling = true, wood = true, stair = true, slab = true, fruitleaves = true, fruit = true, abm = true, craft = true}
end
if not def.wood_by_trunk then
def.wood_by_trunk = 4
end
if not def.names then
def.names = {
tree = "forest:"..specie.."_tree",
leaves = "forest:"..specie.."_leaves",
sapling = "forest:"..specie.."_sapling",
wood = "forest:"..specie.."_wood",
fruitleaves = "forest:"..specie.."_fruitleaves",
fruit = "forest:"..specie.."_fruit",
stair_slab = specie.."_wood"}
end
if def.register.tree then
minetest.register_node(def.names.tree, {
description = def.descriptions.tree,
tiles = {def.tiles.tree_top, def.tiles.tree_top, def.tiles.tree},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
end
trees[specie] = def.growing
trees[specie].nodes = def.names
apportionment[specie] = def.apportionment
if def.register.leaves then
minetest.register_node(def.names.leaves, {
description = def.descriptions.leaves,
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {def.tiles.leaves},
paramtype = "light",
waving = 1,
is_ground_content = false,
groups = {snappy=3, leafdecay=def.growing.radius + 1, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1 out of chance_sapling chance
items = {def.names.sapling},
rarity = 100 / def.sapling.chance,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {def.names.leaves},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
end
if def.register.sapling then
minetest.register_node(def.names.sapling, {
description = def.descriptions.sapling,
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {def.tiles.sapling},
inventory_image = def.tiles.sapling,
wield_image = def.tiles.sapling,
paramtype = "light",
walkable = false,
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
end
if def.register.abm then
minetest.register_abm({
nodenames = {def.names.sapling},
interval = 60,
chance = 100 / def.sapling.growing,
action = function(pos)
def.growing.method(pos, specie)
end
})
end
if def.register.wood then
minetest.register_node(def.names.wood, {
description = def.descriptions.wood,
tiles = {def.tiles.wood},
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
-- Code from stairs
if def.register.stair then
stairs.register_stair(def.names.stair_slab, def.names.wood,
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
{def.tiles.wood},
def.descriptions.stair,
default.node_sound_wood_defaults()
)
end
if def.register.slab then
stairs.register_slab(def.names.stair_slab, def.names.wood,
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
{def.tiles.wood},
def.descriptions.slab,
default.node_sound_wood_defaults()
)
end
end
if def.register.craft then
minetest.register_craft({
output = def.names.wood..' '..def.wood_by_trunk,
recipe = {
{def.names.tree},
}
})
end
if def.fruits then
if def.register.fruitleaves then
minetest.register_node(def.names.fruitleaves, {
description = def.descriptions.fruitleaves,
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {def.tiles.fruitleaves},
paramtype = "light",
waving = 1,
is_ground_content = false,
groups = {snappy=3, dig_immediate=3, leafdecay=def.growing.radius + 1, flammable=2, leaves=1},
drop = {items = {{items = {def.names.fruit}}}},
sounds = default.node_sound_leaves_defaults(),
after_destruct = function(pos)
minetest.set_node(pos, {name = def.names.leaves})
end
})
end
if def.register.fruit then
if def.fruits.hearts > 0 then
minetest.register_craftitem(def.names.fruit, {
description = def.descriptions.fruit,
inventory_image = def.tiles.fruit,
on_use = minetest.item_eat(def.fruits.hearts * 2),
})
else
minetest.register_craftitem(def.names.fruit, {
description = def.descriptions.fruit,
inventory_image = def.tiles.fruit,
})
end
end
minetest.register_abm({
nodenames = {def.names.leaves},
interval = 60,
chance = 100 / def.fruits.chance,
action = function(pos)
minetest.set_node(pos, {name = def.names.fruitleaves})
end
})
minetest.register_abm({
nodenames = {def.names.fruitleaves},
interval = 60,
chance = (100 * def.fruits.max) / (def.fruits.chance * (100 - def.fruits.max)),
action = function(pos)
minetest.set_node(pos, {name = def.names.leaves})
end
})
if def.fruits.craft then
minetest.register_craft({
output = def.fruits.craft,
recipe = {
{def.names.fruit},
}
})
end
if def.fruits.craft_sapling then
minetest.register_craft({
output = def.names.sapling,
recipe = {
{def.names.fruit, def.names.fruit, def.names.fruit},
{def.names.fruit, def.names.fruit, def.names.fruit},
{def.names.fruit, def.names.fruit, def.names.fruit},
}
})
end
end
end

148
seasons.lua Normal file
View File

@ -0,0 +1,148 @@
register_season("flowers:rose", {
type = "disappear",
start = 8.00,
stop = 2.50,
speed = 6,
})
register_season("flowers:rose", {
type = "appear",
start = 4.90,
stop = 10.50,
speed = 8,
})
register_season("flowers:viola", {
type = "disappear",
start = 4.00,
stop = 3.00,
speed = 20,
})
register_season("flowers:viola", {
type = "appear",
start = 3.00,
stop = 4.30,
speed = 25,
})
register_season("flowers:dandelion_white", {
type = "disappear",
start = 5.50,
stop = 1.30,
speed = 7,
})
register_season("flowers:dandelion_white", {
type = "appear",
start = 2.90,
stop = 4.60,
speed = 15,
new_node = {name = "flowers:dandelion_yellow"},
})
register_season("flowers:dandelion_yellow", {
type = "transforms",
start = 4.00,
stop = 8.00,
speed = 5,
})
register_season("flowers:geranium", {
type = "disappear",
start = 9.80,
stop = 6.50,
speed = 6,
})
register_season("flowers:geranium", {
type = "disappear",
start = 5.00,
stop = 9.80,
speed = 1.5,
})
register_season("flowers:geranium", {
type = "appear",
start = 5.00,
stop = 9.20,
speed = 7.5,
})
register_season("flowers:tulip", {
type = "disappear",
start = 5.00,
stop = 3.00,
speed = 20,
})
register_season("flowers:tulip", {
type = "appear",
start = 4.10,
stop = 5.00,
speed = 18,
})
register_season("default:grass_1", {
type = "transforms",
start = 3.00,
stop = 9.00,
speed = 5,
new_node = {name = "default:grass_2"},
})
register_season("default:grass_2", {
type = "transforms",
start = 3.75,
stop = 9.00,
speed = 5,
new_node = {name = "default:grass_3"},
})
register_season("default:grass_3", {
type = "transforms",
start = 4.50,
stop = 9.00,
speed = 5,
new_node = {name = "default:grass_4"},
})
register_season("default:grass_4", {
type = "transforms",
start = 5.25,
stop = 9.00,
speed = 5,
new_node = {name = "default:grass_5"},
})
register_season("default:grass_5", {
type = "transforms",
start = 9.00,
stop = 11.00,
speed = 7,
new_node = {name = "default:grass_4"},
})
register_season("default:grass_4", {
type = "transforms",
start = 9.00,
stop = 11.00,
speed = 7,
new_node = {name = "default:grass_3"},
})
register_season("default:grass_3", {
type = "transforms",
start = 9.00,
stop = 11.00,
speed = 7,
new_node = {name = "default:grass_2"},
})
register_season("default:grass_2", {
type = "transforms",
start = 9.00,
stop = 11.00,
speed = 7,
new_node = {name = "default:grass_1"},
})

BIN
textures/beech_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

BIN
textures/beech_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

BIN
textures/beech_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

BIN
textures/beech_tree_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

BIN
textures/beech_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

BIN
textures/birch_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

BIN
textures/birch_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

BIN
textures/birch_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

BIN
textures/birch_tree_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

BIN
textures/birch_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

BIN
textures/bucket_mud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

BIN
textures/bucket_oil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

BIN
textures/cherry_fruit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

BIN
textures/cherry_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

BIN
textures/clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

BIN
textures/fir_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

BIN
textures/fir_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

BIN
textures/fir_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/fir_tree_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

BIN
textures/fir_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

BIN
textures/ginkgo_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

BIN
textures/ginkgo_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

BIN
textures/ginkgo_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

BIN
textures/ginkgo_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

BIN
textures/gravel_heap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

BIN
textures/gravel_way.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

BIN
textures/lavender_fruit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

BIN
textures/lavender_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

BIN
textures/lavender_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

BIN
textures/leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

BIN
textures/mud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

BIN
textures/mud_animated.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
textures/new_ice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

BIN
textures/oak_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
textures/oak_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

BIN
textures/oak_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

BIN
textures/oak_tree_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

BIN
textures/oak_wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

BIN
textures/oil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
textures/plum_fruit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

BIN
textures/plum_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

BIN
textures/sand_heap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

BIN
textures/sand_way.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

BIN
textures/thermometer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

BIN
textures/thermometer_0b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_1b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_2b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_3b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_4b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_5b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_6b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_7b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_8b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/thermometer_9b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
textures/willow_leaves.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

BIN
textures/willow_sapling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
textures/willow_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Some files were not shown because too many files have changed in this diff Show More