forked from mtcontrib/watershed
acaciatree, pinetree nodes. bugix spawn function. biome blend
This commit is contained in:
parent
b1f138c74c
commit
903acd2ae0
|
@ -1,4 +1,4 @@
|
|||
watershed 0.3.7 by paramat
|
||||
watershed 0.3.8 by paramat
|
||||
For latest stable Minetest back to 0.4.8
|
||||
Depends default bucket
|
||||
Licenses: code WTFPL, textures CC BY-SA
|
||||
|
|
|
@ -30,7 +30,7 @@ function watershed_appletree(x, y, z, area, data)
|
|||
end
|
||||
|
||||
function watershed_pinetree(x, y, z, area, data)
|
||||
local c_tree = minetest.get_content_id("default:tree")
|
||||
local c_wspitree = minetest.get_content_id("watershed:pinetree")
|
||||
local c_wsneedles = minetest.get_content_id("watershed:needles")
|
||||
local c_snowblock = minetest.get_content_id("default:snowblock")
|
||||
for j = -4, 14 do
|
||||
|
@ -75,7 +75,7 @@ function watershed_pinetree(x, y, z, area, data)
|
|||
end
|
||||
end
|
||||
local vit = area:index(x, y + j, z)
|
||||
data[vit] = c_tree
|
||||
data[vit] = c_wspitree
|
||||
end
|
||||
local vil = area:index(x, y + 15, z)
|
||||
local vila = area:index(x, y + 16, z)
|
||||
|
@ -129,8 +129,8 @@ function watershed_jungletree(x, y, z, area, data)
|
|||
end
|
||||
|
||||
function watershed_acaciatree(x, y, z, area, data)
|
||||
local c_tree = minetest.get_content_id("default:tree")
|
||||
local c_wsaccleaf = minetest.get_content_id("watershed:acacialeaf")
|
||||
local c_wsactree = minetest.get_content_id("watershed:acaciatree")
|
||||
local c_wsacleaf = minetest.get_content_id("watershed:acacialeaf")
|
||||
for j = -3, 6 do
|
||||
if j == 6 then
|
||||
for i = -4, 4 do
|
||||
|
@ -138,7 +138,7 @@ function watershed_acaciatree(x, y, z, area, data)
|
|||
if not (i == 0 or k == 0) then
|
||||
if math.random(7) ~= 2 then
|
||||
local vil = area:index(x + i, y + j, z + k)
|
||||
data[vil] = c_wsaccleaf
|
||||
data[vil] = c_wsacleaf
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -147,7 +147,7 @@ function watershed_acaciatree(x, y, z, area, data)
|
|||
for i = -2, 2, 4 do
|
||||
for k = -2, 2, 4 do
|
||||
local vit = area:index(x + i, y + j, z + k)
|
||||
data[vit] = c_tree
|
||||
data[vit] = c_wsactree
|
||||
end
|
||||
end
|
||||
elseif j == 4 then
|
||||
|
@ -155,13 +155,13 @@ function watershed_acaciatree(x, y, z, area, data)
|
|||
for k = -1, 1 do
|
||||
if math.abs(i) + math.abs(k) == 2 then
|
||||
local vit = area:index(x + i, y + j, z + k)
|
||||
data[vit] = c_tree
|
||||
data[vit] = c_wsactree
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local vit = area:index(x, y + j, z)
|
||||
data[vit] = c_tree
|
||||
data[vit] = c_wsactree
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -247,15 +247,7 @@ if SINGLENODE then
|
|||
spread = {x=512, y=512, z=512},
|
||||
seed = 593,
|
||||
octaves = 6,
|
||||
persist = 0.3
|
||||
}
|
||||
local np_fault = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=1024, z=512},
|
||||
seed = 14440002,
|
||||
octaves = 6,
|
||||
persist = 0.5
|
||||
persist = 0.4
|
||||
}
|
||||
local np_base = {
|
||||
offset = 0,
|
||||
|
@ -273,23 +265,7 @@ if SINGLENODE then
|
|||
octaves = 3,
|
||||
persist = 0.4
|
||||
}
|
||||
local np_temp = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=512, z=512},
|
||||
seed = 9130,
|
||||
octaves = 2,
|
||||
persist = 0.5
|
||||
}
|
||||
local np_humid = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=512, z=512},
|
||||
seed = -55500,
|
||||
octaves = 2,
|
||||
persist = 0.5
|
||||
}
|
||||
for chunk = 1, 32 do
|
||||
for chunk = 1, 64 do
|
||||
print ("[watershed] searching for spawn "..chunk)
|
||||
local x0 = 80 * math.random(-24, 24) - 32
|
||||
local z0 = 80 * math.random(-24, 24) - 32
|
||||
|
@ -305,9 +281,6 @@ if SINGLENODE then
|
|||
|
||||
local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz)
|
||||
local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz)
|
||||
local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz)
|
||||
local nvals_temp = minetest.get_perlin_map(np_temp, chulens):get3dMap_flat(minposxyz)
|
||||
local nvals_humid = minetest.get_perlin_map(np_humid, chulens):get3dMap_flat(minposxyz)
|
||||
|
||||
local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz)
|
||||
local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
|
||||
|
@ -317,22 +290,12 @@ if SINGLENODE then
|
|||
for z = z0, z1 do
|
||||
for y = y0, y1 do
|
||||
for x = x0, x1 do
|
||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
||||
local n_base = nvals_base[nixz]
|
||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
||||
local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
|
||||
local terblen = math.max(1 - math.abs(n_base), 0)
|
||||
local n_temp = nvals_temp[nixyz]
|
||||
local n_humid = nvals_humid[nixyz]
|
||||
local density
|
||||
if nvals_fault[nixyz] >= 0 then
|
||||
density = densitybase
|
||||
+ math.abs(nvals_rough[nixyz] * terblen
|
||||
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_temp * 0.5)
|
||||
else
|
||||
density = densitybase
|
||||
+ math.abs(nvals_rough[nixyz] * terblen
|
||||
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_humid * 0.5)
|
||||
end
|
||||
local density = densitybase
|
||||
+ math.abs(nvals_rough[nixyz] * terblen + nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP
|
||||
if y >= 1 and density > -0.01 and density < 0 then
|
||||
ysp = y + 1
|
||||
xsp = x
|
||||
|
@ -372,9 +335,11 @@ end
|
|||
|
||||
-- ABM
|
||||
|
||||
-- update luxore light
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"watershed:luxoreoff"},
|
||||
interval = 7,
|
||||
interval = 13,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.remove_node(pos)
|
||||
|
|
35
init.lua
35
init.lua
|
@ -1,12 +1,16 @@
|
|||
-- watershed 0.3.7 by paramat
|
||||
-- watershed 0.3.8 by paramat
|
||||
-- For latest stable Minetest and back to 0.4.8
|
||||
-- Depends default bucket
|
||||
-- License: code WTFPL, textures CC BY-SA
|
||||
-- Red cobble texture CC BY-SA by brunob.santos minetestbr.blogspot.com
|
||||
|
||||
-- thicker layer of redstone in deserts
|
||||
-- ice thicker with lower temperature
|
||||
-- papyrus on riverbank not beach
|
||||
-- pine, acacia tree trunks
|
||||
-- bugfix spawning function
|
||||
-- temperature / humidity randomness for biome blend
|
||||
-- TODO
|
||||
-- pine wood
|
||||
-- acacia wood
|
||||
-- better appletree design with branches
|
||||
|
||||
-- Parameters
|
||||
|
||||
|
@ -28,7 +32,7 @@ local TSTONE = 0.02 -- Density threshold for stone, depth of soil at TERCEN
|
|||
local TRIV = -0.02 -- Maximum densitybase threshold for river water
|
||||
local TSAND = -0.025 -- Maximum densitybase threshold for river sand
|
||||
local TLAVA = 2.3 -- Maximum densitybase threshold for lava, small because grad is non-linear
|
||||
local FISEXP = 0.02 -- Fissure expansion rate under surface
|
||||
local FISEXP = 0.03 -- Fissure expansion rate under surface
|
||||
local ORETHI = 0.002 -- Ore seam thickness tuner
|
||||
local SEAMT = 0.2 -- Seam threshold, width of seams
|
||||
local ICETHI = 32 -- Controls maximum ice thickness
|
||||
|
@ -38,19 +42,20 @@ local LOTET = -0.35 -- Low ..
|
|||
local ICETET = -0.7 -- Ice ..
|
||||
local HIHUT = 0.35 -- High humidity threshold
|
||||
local LOHUT = -0.35 -- Low ..
|
||||
local BLEND = 0.03 -- Biome blend randomness
|
||||
|
||||
local PINCHA = 36 -- Pine tree 1/x chance per node
|
||||
local APTCHA = 36 -- Appletree
|
||||
local FLOCHA = 36 -- Flower
|
||||
local FOGCHA = 9 -- Forest grass
|
||||
local GRACHA = 3 -- Grassland grasses
|
||||
local GRACHA = 4 -- Grassland grasses
|
||||
local JUTCHA = 16 -- Jungletree
|
||||
local JUGCHA = 9 -- Junglegrass
|
||||
local CACCHA = 841 -- Cactus
|
||||
local DRYCHA = 169 -- Dry shrub
|
||||
local PAPCHA = 2 -- Papyrus
|
||||
local ACACHA = 529 -- Acacia tree
|
||||
local GOGCHA = 3 -- Golden grass
|
||||
local GOGCHA = 4 -- Golden grass
|
||||
|
||||
-- 3D noise for rough terrain
|
||||
|
||||
|
@ -70,7 +75,7 @@ local np_smooth = {
|
|||
scale = 1,
|
||||
spread = {x=512, y=512, z=512},
|
||||
seed = 593,
|
||||
octaves = 5,
|
||||
octaves = 6,
|
||||
persist = 0.4
|
||||
}
|
||||
|
||||
|
@ -266,20 +271,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local n_rough = nvals_rough[nixyz] -- noise values for node
|
||||
local n_smooth = nvals_smooth[nixyz]
|
||||
local n_fissure = nvals_fissure[nixyz]
|
||||
local n_temp = nvals_temp[nixyz]
|
||||
local n_humid = nvals_humid[nixyz]
|
||||
local n_temp = nvals_temp[nixyz] + (math.random() - 0.5) * BLEND
|
||||
local n_humid = nvals_humid[nixyz] + (math.random() - 0.5) * BLEND
|
||||
local n_seam = nvals_seam[nixyz]
|
||||
local n_strata = nvals_strata[nixyz]
|
||||
|
||||
local n_base = nvals_base[nixz]
|
||||
local n_xlscale = nvals_xlscale[nixz]
|
||||
local n_magma = nvals_magma[nixz]
|
||||
|
||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP -- get densitybase and density
|
||||
local densitybase = (1 - math.abs(n_base)) * BASAMP + n_xlscale * XLSAMP + grad
|
||||
local terblen = math.max(1 - math.abs(n_base), 0)
|
||||
-- get densitybase and density
|
||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP -- vertical density gradient
|
||||
local densitybase = (1 - math.abs(n_base)) * BASAMP + n_xlscale * XLSAMP + grad -- base terrain or ridge networks
|
||||
local terblen = math.max(1 - math.abs(n_base), 0) -- terrain blend rough and smooth
|
||||
local density = densitybase
|
||||
+ math.abs(n_rough * terblen + n_smooth * (1 - terblen)) ^ CANEXP * CANAMP
|
||||
+ math.abs(n_rough * terblen + n_smooth * (1 - terblen)) ^ CANEXP * CANAMP -- add canyon terrain
|
||||
|
||||
local triv = TRIV * (1 - terblen) -- other values
|
||||
local tsand = TSAND * (1 - terblen)
|
||||
|
|
20
nodes.lua
20
nodes.lua
|
@ -13,13 +13,22 @@ minetest.register_node("watershed:acacialeaf", {
|
|||
description = "WS Acacia Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves.png"},
|
||||
tiles = {"watershed_acacialeaf.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, flammable=2, leaves=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:acaciatree", {
|
||||
description = "WS Acacia Tree",
|
||||
tiles = {"watershed_acaciatreetop.png", "watershed_acaciatreetop.png", "watershed_acaciatree.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:needles", {
|
||||
description = "WS Pine Needles",
|
||||
drawtype = "allfaces_optional",
|
||||
|
@ -31,6 +40,15 @@ minetest.register_node("watershed:needles", {
|
|||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:pinetree", {
|
||||
description = "WS Pine Tree",
|
||||
tiles = {"watershed_pinetreetop.png", "watershed_pinetreetop.png", "watershed_pinetree.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:jungleleaf", {
|
||||
description = "WS Jungletree Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
|
|
BIN
textures/watershed_acacialeaf.png
Normal file
BIN
textures/watershed_acacialeaf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 340 B |
BIN
textures/watershed_acaciatree.png
Normal file
BIN
textures/watershed_acaciatree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 682 B |
BIN
textures/watershed_acaciatreetop.png
Normal file
BIN
textures/watershed_acaciatreetop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 731 B |
BIN
textures/watershed_pinetree.png
Normal file
BIN
textures/watershed_pinetree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 693 B |
BIN
textures/watershed_pinetreetop.png
Normal file
BIN
textures/watershed_pinetreetop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 802 B |
Loading…
Reference in New Issue
Block a user