Version 4.0 Beta

Complete overhaul of the lake generator, much more efficient now.
Sandstone biome added, look for it in low humidity areas.  Heaven biome
implementation started, uncomment the code to preview.
master
Chris N 2014-07-17 17:51:08 -10:00
parent b53d12658d
commit 43b409341a
15 changed files with 474 additions and 295 deletions

View File

@ -25,6 +25,29 @@ function skylands:appletree(x, y, z, area, data)
end
end
function skylands:goldentree(x, y, z, area, data)
local c_tree = minetest.get_content_id("default:tree")
local c_gapple = minetest.get_content_id("skylands:golden_apple")
local c_gleaves = minetest.get_content_id("skylands:golden_leaves")
for j = -2, 4 do
if j >= 1 then
for i = -2, 2 do
for k = -2, 2 do
local vi = area:index(x + i, y + j + 1, z + k)
if math.random(48) == 2 then
data[vi] = c_gapple
elseif math.random(3) ~= 2 then
data[vi] = c_gleaves
end
end
end
end
local vi = area:index(x, y + j, z)
data[vi] = c_tree
end
end
function skylands:grass(data, vi)
local c_grass1 = minetest.get_content_id("default:grass_1")
local c_grass2 = minetest.get_content_id("default:grass_2")

357
init.lua
View File

@ -1,4 +1,4 @@
-- skylands 3.1 by HeroOfTheWinds, based on floatindev 0.2.0 by paramat
-- skylands 4.0 by HeroOfTheWinds, based on floatindev 0.2.0 by paramat
-- For latest stable Minetest and back to 0.4.8
-- Depends default, fire, moreblocks?, moreores?, mesecons?
-- License: code WTFPL
@ -12,8 +12,6 @@ local XMAX = 33000
local ZMIN = -33000
local ZMAX = 33000
local FLOW = 256 --for pools
local CHUINT = 4 -- Chunk interval for floatland layers
local WAVAMP = 24 --16 -- Structure wave amplitude
local HISCAL = 128 --24 -- Upper structure vertical scale
@ -23,6 +21,7 @@ local LOEXP = 0.33 -- Lower structure density gradient exponent
local CLUSAV = -0.4 -- Large scale variation average
local CLUSAM = 0.5 -- Large scale variation amplitude
local DIRTHR = 0.04 -- Dirt density threshold
local SANTHR = 0.05 -- Sandstone density threshold
local STOTHR = 0.08 -- Stone density threshold
local STABLE = 2 -- Minimum number of stacked stone nodes in column for dirt / sand on top
@ -39,6 +38,9 @@ local FIRCHA = 0.03 -- Fire chance
local LAKCHA = 0.002
local ORECHA = 1 / (6 * 6 * 6)
local HEAVEN = 10000 --altitude at which "heaven" islands begin appearing
local HEAVINT = 800 --interval between "heaven" layers; also determines layer width
-- 3D noise for floatlands
local np_float = {
@ -124,6 +126,7 @@ dofile(minetest.get_modpath("skylands").."/nodes.lua")
dofile(minetest.get_modpath("skylands").."/wheat.lua")
dofile(minetest.get_modpath("skylands").."/abms.lua")
dofile(minetest.get_modpath("skylands").."/functions.lua")
dofile(minetest.get_modpath("skylands").."/pools.lua")
@ -176,6 +179,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_dryshrub = minetest.get_content_id("default:dry_shrub")
local c_dirt = minetest.get_content_id("default:dirt")
local c_desand = minetest.get_content_id("default:desert_sand")
local c_sand = minetest.get_content_id("default:sand")
local c_stosand = minetest.get_content_id("default:sandstone")
--Newly added
local c_snow = minetest.get_content_id("default:dirt_with_snow")
local c_fliobsidian = minetest.get_content_id("skylands:obsidian")
@ -203,6 +208,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_drygrass = minetest.get_content_id("skylands:drygrass")
local c_permafrost = minetest.get_content_id("skylands:permafrost")
--Heaven biome nodes
local c_stowhite = minetest.get_content_id("skylands:white_stone")
local c_richdirt = minetest.get_content_id("skylands:rich_dirt")
local c_hvngrass = minetest.get_content_id("skylands:heaven_grass")
local sidelen = (x1 - x0 + 1)
local chulens = {x=sidelen, y=sidelen, z=sidelen}
local minposxyz = {x=x0, y=y0, z=z0}
@ -218,6 +228,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
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 lakepoints = {} --table to store points to scan for lake generation
local li = 1 --index for lakepoints
local nixyz = 1
local nixz = 1
local stable = {}
@ -264,7 +277,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
elseif n_temp > 0.35 then
if n_humid < -0.35 then
biome = 7 -- desert
if n_humid < -0.50 then
biome = 7 -- desert
else
biome = 11 --sand(stone) borderland
end
elseif n_humid > 0.35 then
biome = 9 -- rainforest
else
@ -284,10 +301,22 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
--NOT FULLY IMPLEMENTED, UNCOMMENT ONLY IF YOU WANT A SHODDY PREVIEW!
--if y >= HEAVEN and y < HEAVEN + HEAVINT then
--biome = 12 --heaven
--end
if y > flomid and density < STOTHR and stable[si] >= STABLE then
if biome == 7 then
data[vi] = c_desand
dirt[si] = dirt[si] + 1
elseif biome == 11 then --sand border
if density < SANTHR then
data[vi] = c_sand --make sand
else
data[vi] = c_stosand --or sandstone
end
dirt[si] = dirt[si] + 1
elseif biome == 4 or biome == 8 then --dry grassland or savanna
if density < DIRTHR then
data[vi] = c_drygrass
@ -338,6 +367,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
dirt[si] = dirt[si] + 1
elseif biome == 12 then
if density < DIRTHR then
data[vi] = c_hvngrass
else
data[vi] = c_richdirt
end
dirt[si] = dirt[si] + 1
else
if density < DIRTHR then
data[vi] = c_grass
@ -359,6 +395,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[vi] = c_fliobsidian
end
end
elseif biome == 12 then
data[vi] = c_stowhite
elseif biome == 2 then
if mblocks then
data[vi] = c_ironstone
@ -438,7 +476,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
elseif n_temp > 0.35 then
if n_humid < -0.35 then
biome = 7 -- desert
if n_humid < -0.50 then
biome = 7 -- desert
else
biome = 11 --sand(stone) borderland
end
elseif n_humid > 0.35 then
biome = 9 -- rainforest
else
@ -457,14 +499,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
biome = 5 -- grassland
end
end
--NOT FULLY IMPLEMENTED, UNCOMMENT ONLY IF YOU WANT A SHODDY PREVIEW!
--if y >= HEAVEN and y < HEAVEN + HEAVINT then
--biome = 12 --heaven
--end
if nvals_biome[nixz] <= 0.65 then --not volcano
if biome == 7 then --desert
if biome == 7 or biome == 11 then --desert
if dirt[si] >= 2 and math.random() < CACCHA then
skylands:desertplant(data, vi)
end
dirt[si] = 0
elseif biome == 5 then --grassland
lakepoints[li] = {x=x,y=y,z=z}
li = li + 1
if dirt[si] >= 2 and math.random() < (APPCHA * 0.5) then
skylands:appletree(x, y, z, area, data)
elseif math.random() < FLOCHA then
@ -473,10 +521,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
skylands:grass(data, vi)
end
dirt[si] = 0
elseif biome == 12 then --heaven
if dirt[si] >= 2 and math.random() < (APPCHA * 0.7) then
skylands:goldentree(x, y, z, area, data)
elseif math.random() < FLOCHA then
skylands:flower(data, vi)
elseif math.random() < GRACHA then
skylands:grass(data, vi)
end
dirt[si] = 0
elseif biome == 10 then --wheat field
skylands:wheat(data, vi)
dirt[si] = 0
elseif biome == 6 then --deciduous forest
lakepoints[li] = {x=x,y=y,z=z}
li = li + 1
if dirt[si] >= 2 and math.random() < APPCHA then
skylands:appletree(x, y, z, area, data)
end
@ -492,6 +551,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
dirt[si] = 0
elseif biome == 2 then --snowy plains
lakepoints[li] = {x=x,y=y,z=z}
li = li + 1
if dirt[si] >= 2 and math.random() < SPINCHA then
skylands:pinetree(x, y, z, area, data)
end
@ -504,6 +565,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
dirt[si] = 0
elseif biome == 9 then --rainforest
lakepoints[li] = {x=x,y=y,z=z}
li = li + 1
if dirt[si] >= 2 and math.random() < JUNTCHA then
skylands:jungletree(x, y, z, area, data)
elseif math.random() < JUNGCHA then
@ -514,6 +577,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
else --volcano
--skylands:remtree(x, y, z, area, data)
--data[vi] = c_air
lakepoints[li] = {x=x,y=y,z=z}
li = li + 1
if math.random() < FIRCHA then
data[vi] = c_fire
end
@ -531,283 +596,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
nixz = nixz + 80
end
--pools code
local y0 = minp.y
if y0 < YMIN or y0 > YMAX then
return
end
local t1 = os.clock()
local x0 = minp.x
local z0 = minp.z
print ("[highlandpools] chunk ("..x0.." "..y0.." "..z0..")")
local x1 = maxp.x
local y1 = maxp.y
local z1 = maxp.z
local sidelen = x1 - x0 -- actually sidelen - 1
local c_ignore = minetest.get_content_id("ignore")
local c_watsour = minetest.get_content_id("default:water_source")
local c_lavasour = minetest.get_content_id("default:lava_source")
local c_ice = minetest.get_content_id("default:ice")
local c_tree = minetest.get_content_id("default:tree")
local c_apple = minetest.get_content_id("default:apple")
local c_leaves = minetest.get_content_id("default:leaves")
for xcen = x0 + 8, x1 - 7, 8 do
for zcen = z0 + 8, z1 - 7, 8 do
local yasurf = false -- y of above surface node
local fluidtype = "water" --type of fluid to fill in
for y = y1, 2, -1 do
local vi = area:index(xcen, y, zcen)
local c_node = data[vi]
if y == y1 and c_node ~= c_air then -- if top node solid
break
elseif c_node == c_watsour then
break
elseif c_node == c_grass then
yasurf = y + 1
fluidtype = "water"
break
elseif c_node == c_snow then
yasurf = y + 1
fluidtype = "ice"
break
elseif c_node == c_cinder then
yasurf = y + 1
fluidtype = "lava"
break
elseif c_node == c_gravel then
yasurf = y + 1
fluidtype = "lava"
break
elseif c_node == c_obsidian then
yasurf = y + 1
fluidtype = "lava"
break
end
end
if yasurf then
local abort = false
for ser = 1, 80 do
local vi = area:index(xcen + ser, yasurf, zcen)
local c_node = data[vi]
if xcen + ser == x1 then
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
break
end
end
for ser = 1, 80 do
local vi = area:index(xcen - ser, yasurf, zcen)
local c_node = data[vi]
if xcen - ser == x0 then
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
break
end
end
for ser = 1, 80 do
local vi = area:index(xcen, yasurf, zcen + ser)
local c_node = data[vi]
if zcen + ser == z1 then
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
break
end
end
for ser = 1, 80 do
local vi = area:index(xcen, yasurf, zcen - ser)
local c_node = data[vi]
if zcen - ser == z0 then
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
break
end
end
if abort then
break
end
local vi = area:index(xcen, yasurf, zcen)
if fluidtype == "water" then
data[vi] = c_watsour
elseif fluidtype == "lava" then
data[vi] = c_lavasour
elseif fluidtype == "ice" then
data[vi] = c_ice
end
local flab = false -- flow abort
for flow = 1, FLOW do
for z = z0, z1 do
for x = x0, x1 do
local vif = area:index(x, yasurf, z)
if data[vif] == c_watsour or data[vif] == c_lavasour or data[vif] == c_ice then
if x == x0 or x == x1 or z == z0 or z == z1 then
flab = true -- if water at chunk edge abort flow
break
else -- flow water
local vie = area:index(x + 1, yasurf, z)
local viw = area:index(x - 1, yasurf, z)
local vin = area:index(x, yasurf, z + 1)
local vis = area:index(x, yasurf, z - 1)
if data[vie] == c_tree then
skylands:remtree(x + 1, yasurf, z, area, data)
if fluidtype == "water" then
data[vie] = c_watsour
elseif fluidtype == "lava" then
data[vie] = c_lavasour
elseif fluidtype == "ice" then
data[vie] = c_ice
end
elseif data[vie] == c_air
or data[vie] == c_apple
or data[vie] == c_fire
or data[vie] == c_leaves then
skylands:remplant(x + 1, yasurf, z, area, data)
if fluidtype == "water" then
data[vie] = c_watsour
elseif fluidtype == "lava" then
data[vie] = c_lavasour
elseif fluidtype == "ice" then
data[vie] = c_ice
end
end
if data[viw] == c_tree then
skylands:remtree(x - 1, yasurf, z, area, data)
if fluidtype == "water" then
data[viw] = c_watsour
elseif fluidtype == "lava" then
data[viw] = c_lavasour
elseif fluidtype == "ice" then
data[viw] = c_ice
end
elseif data[viw] == c_air
or data[viw] == c_apple
or data[viw] == c_fire
or data[viw] == c_leaves then
skylands:remplant(x + 1, yasurf, z, area, data)
if fluidtype == "water" then
data[viw] = c_watsour
elseif fluidtype == "lava" then
data[viw] = c_lavasour
elseif fluidtype == "ice" then
data[viw] = c_ice
end
end
if data[vin] == c_tree then
skylands:remtree(x, yasurf, z + 1, area, data)
if fluidtype == "water" then
data[vin] = c_watsour
elseif fluidtype == "lava" then
data[vin] = c_lavasour
elseif fluidtype == "ice" then
data[vin] = c_ice
end
elseif data[vin] == c_air
or data[vin] == c_apple
or data[vin] == c_fire
or data[vin] == c_leaves then
skylands:remplant(x + 1, yasurf, z, area, data)
if fluidtype == "water" then
data[vin] = c_watsour
elseif fluidtype == "lava" then
data[vin] = c_lavasour
elseif fluidtype == "ice" then
data[vin] = c_ice
end
end
if data[vis] == c_tree then
skylands:remtree(x, yasurf, z - 1, area, data)
if fluidtype == "water" then
data[vis] = c_watsour
elseif fluidtype == "lava" then
data[vis] = c_lavasour
elseif fluidtype == "ice" then
data[vis] = c_ice
end
elseif data[vis] == c_air
or data[vis] == c_apple
or data[vis] == c_fire
or data[vis] == c_leaves then
skylands:remplant(x + 1, yasurf, z, area, data)
if fluidtype == "water" then
data[vis] = c_watsour
elseif fluidtype == "lava" then
data[vis] = c_lavasour
elseif fluidtype == "ice" then
data[vis] = c_ice
end
end
end
end
end
if flab then
break
end
end
if flab then
break
end
end
if flab then -- erase water from this y level
for z = z0, z1 do
for x = x0, x1 do
local vi = area:index(x, yasurf, z)
if data[vi] == c_watsour then
data[vi] = c_air
end
if data[vi] == c_lavasour then
data[vi] = c_air
end
if data[vi] == c_ice then
data[vi] = c_air
end
end
end
else -- flow downwards add dirt
for z = z0, z1 do
for x = x0, x1 do
local vi = area:index(x, yasurf, z)
if data[vi] == c_watsour or data[vif] == c_lavasour then
for y = yasurf - 1, y0, -1 do
local viu = area:index(x, y, z)
if data[viu] == c_air then
if fluidtype == "water" or fluidtype == "ice" then
data[viu] = c_watsour
elseif fluidtype == "lava" then
data[viu] = c_lavasour
end
elseif data[viu] == c_grass or data[viu] == c_snow then
data[viu] = c_dirt
break
elseif data[viu] == c_cinder or data[viu] == c_gravel then
data[viu] = c_fliobsidian
break
else
skylands:remplant(x + 1, yasurf, z, area, data)
break
end
end
end
end
end
end
end
end
end
skylands:gen_pool(lakepoints, area, data, x0, z0, x1, z1)
vm:set_data(data)
vm:set_lighting({day=0, night=0})

152
nodes.lua
View File

@ -1,5 +1,7 @@
-- Nodes
-- REDEFINITIONS --
minetest.register_node("skylands:stone", {
description = "FLI Stone",
tiles = {"default_stone.png"},
@ -26,6 +28,26 @@ minetest.register_node("skylands:obsidian", {
groups = {cracky=1,level=2},
drop = "default:obsidian",
})
--moreblocks nodes - iron_stone redefined so that cavegen doesn't destroy
minetest.register_node("skylands:coal_stone", {
description = "FLI Coal Stone",
tiles = {"moreblocks_coal_stone.png"},
--is_ground_content = false,
groups = {cracky=3},
drop = "moreblocks:coal_stone",
})
minetest.register_node("skylands:iron_stone", {
description = "FLI Iron Stone",
tiles = {"moreblocks_iron_stone.png"},
is_ground_content = false,
groups = {cracky=3},
drop = "moreblocks:iron_stone",
})
-- UNIQUE NODES --
--NEW! Cinder for volcanic biomes
minetest.register_node("skylands:cinder", {
description = "Cinder",
@ -52,22 +74,128 @@ minetest.register_craft({
{"skylands:cinder", "skylands:cinder"}
}
})
--moreblocks nodes - iron_stone redefined so that cavegen doesn't destroy
minetest.register_node("skylands:coal_stone", {
description = "FLI Coal Stone",
tiles = {"moreblocks_coal_stone.png"},
--is_ground_content = false,
groups = {cracky=3},
drop = "moreblocks:coal_stone",
--gold heaven grass for heaven biome... rich soil
minetest.register_node("skylands:heaven_grass", {
description = "Dirt with Heaven Grass",
tiles = {"skylands_heavengrass.png", "default_dirt.png", "default_dirt.png^skylands_heavengrass_side.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = 'skylands:rich_dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node("skylands:iron_stone", {
description = "FLI Iron Stone",
tiles = {"moreblocks_iron_stone.png"},
minetest.register_node("skylands:rich_dirt", {
description = "Rich Dirt",
tiles = {"skylands_rich_dirt.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
sounds = default.node_sound_dirt_defaults(),
})
--golden leaves for heaven trees
minetest.register_node("skylands:golden_leaves", {
description = "Golden Leaves",
drawtype = "allfaces_optional",
waving = 1,
visual_scale = 1.3,
tiles = {"skylands_goldleaves.png"},
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
})
--golden apples
minetest.register_node("skylands:golden_apple", {
description = "Golden Apple",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"skylands_golden_apple.png"},
inventory_image = "skylands_golden_apple.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
},
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
on_use = minetest.item_eat(4),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.set_node(pos, {name="skylands:golden_apple", param2=1})
end
end,
})
--white stone for Heaven biome
minetest.register_node("skylands:white_stone", {
description = "White Stone",
tiles = {"skylands_white_stone.png"},
is_ground_content = false,
groups = {cracky=3},
drop = "moreblocks:iron_stone",
drop = "skylands:white_cobble",
})
minetest.register_node("skylands:white_cobble", {
description = "White Cobblestone",
tiles = {"skylands_white_cobble.png"},
is_ground_content = false,
groups = {cracky=3},
})
minetest.register_node("skylands:white_stone_brick", {
description = "White Stone Brick",
tiles = {"skylands_white_stone_brick.png"},
groups = {cracky=2},
sounds = default.node_sound_stone_defaults(),
})
--Craft to create white stone brick from 4 white stone blocks
minetest.register_craft({
output = "skylands:white_stone_brick",
recipe = {
{"skylands:white_stone", "skylands:white_stone"},
{"skylands:white_stone", "skylands:white_stone"}
}
})
--smelt some white stone from white cobble
minetest.register_craft({
type = "cooking",
output = "skylands:white_stone",
recipe ="skylands:white_cobble"
})
--quartz blocks for heaven biome
minetest.register_node("skylands:quartz", {
description = "Quartz",
tiles = {"skylands_quartz.png"},
groups = {cracky=2},
sounds = default.node_sound_stone_defaults(),
})
--quartz pillars for heaven biome
minetest.register_node("skylands:quartz_pillar", {
description = "Quartz Pillar",
tiles = {"skylands_quartz.png", "skylands_quartz.png", "skylands_quartz_pillar.png"},
groups = {cracky=2},
sounds = default.node_sound_stone_defaults(),
})
--recipe for quartz pillars
minetest.register_craft({
output = "skylands:quartz_pillar 3",
recipe = {
{"skylands:quartz"},
{"skylands:quartz"},
{"skylands:quartz"}
}
})
--define special flame so that it does not expire
minetest.register_node("skylands:constant_flame", {
description = "Fire",
@ -93,6 +221,8 @@ minetest.register_node("skylands:constant_flame", {
end,
})
-- ORES --
--Define the ores so that they propagate with the abm
minetest.register_node("skylands:stone_with_coal", {
description = "Coal Ore",

237
pools.lua Normal file
View File

@ -0,0 +1,237 @@
--pools code
local FLOW = 256
function skylands:gen_pool(lakepoints, area, data, x0, z0, x1, z1)
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_watsour = minetest.get_content_id("default:water_source")
local c_lavasour = minetest.get_content_id("default:lava_source")
local c_ice = minetest.get_content_id("default:ice")
local c_grass = minetest.get_content_id("default:dirt_with_grass")
local c_tree = minetest.get_content_id("default:tree")
local c_apple = minetest.get_content_id("default:apple")
local c_leaves = minetest.get_content_id("default:leaves")
local c_dirt = minetest.get_content_id("default:dirt")
local c_snow = minetest.get_content_id("default:dirt_with_snow")
local c_cinder = minetest.get_content_id("skylands:cinder")
local c_gravel = minetest.get_content_id("default:gravel")
local c_obsidian = minetest.get_content_id("skylands:obsidian")
local sidelen = x1 - x0 -- actually sidelen - 1
--for xcen = x0 + 8, x1 - 7, 8 do
--for zcen = z0 + 8, z1 - 7, 8 do
for _, p in pairs(lakepoints) do --for index, point in table do
--print("there are points. This is "..minetest.pos_to_string(p)..".")
local xcen = p.x
local yasurf = p.y -- y of above surface node
local zcen = p.z
local surf = false
local ftype = "water"
--for y = y1, 2, -1 do
local vi = area:index(xcen, yasurf - 1, zcen)
local c_node = data[vi]
--if y == y1 and c_node ~= c_air then -- if top node solid
--break
if c_node == c_watsour then
break
elseif c_node == c_grass then
ftype = "water"
surf = true
elseif c_node == c_snow then
ftype = "ice"
surf = true
elseif c_node == c_cinder then
ftype = "lava"
surf = true
elseif c_node == c_gravel then
ftype = "lava"
surf = true
elseif c_node == c_obsidian then
ftype = "lava"
surf = true
end
--end
if surf then
--print("now proceeding")
local abort = false
for ser = 1, 80 do
--print("x+")
local vi = area:index(xcen + ser, yasurf, zcen)
local c_node = data[vi]
if xcen + ser == x1 then
--print("Abort x+")
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
--print("found x+ edge")
break
end
end
for ser = 1, 80 do
--print("x-")
local vi = area:index(xcen - ser, yasurf, zcen)
local c_node = data[vi]
if xcen - ser == x0 then
--print("Abort x-")
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
--print("found x-")
break
end
end
for ser = 1, 80 do
--print("y+")
local vi = area:index(xcen, yasurf, zcen + ser)
local c_node = data[vi]
if zcen + ser == z1 then
--print("abort y+")
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
--print("y+ found")
break
end
end
for ser = 1, 80 do
--print("y-")
local vi = area:index(xcen, yasurf, zcen - ser)
local c_node = data[vi]
if zcen - ser == z0 then
--print("y- aborted")
abort = true
elseif c_node ~= c_air
and c_node ~= c_tree
and c_node ~= c_leaves
and c_node ~= c_apple then
--print("y- found")
break
end
end
local flab = false
if abort then
--print("aborted?!")
flab = true
end
--create an easy, clean reference for the current fluid type
local c_fluid = c_watsour
local c_under = c_watsour
if ftype == "lava" then
c_fluid = c_lavasour
c_under = c_lavasour
elseif c_fluid == "ice" then
c_fluid = c_ice
c_under = c_watsour
end
local vi = area:index(xcen, yasurf, zcen)
data[vi] = c_fluid
--local flab = false -- flow abort
--print("wow, made it to here")
for flow = 1, FLOW do
for z = z0, z1 do
for x = x0, x1 do
local vif = area:index(x, yasurf, z)
if data[vif] == c_fluid then
if x == x0 or x == x1 or z == z0 or z == z1 then
flab = true -- if water at chunk edge abort flow
break
else -- flow water
local vie = area:index(x + 1, yasurf, z)
local viw = area:index(x - 1, yasurf, z)
local vin = area:index(x, yasurf, z + 1)
local vis = area:index(x, yasurf, z - 1)
if data[vie] == c_tree then
skylands:remtree(x + 1, yasurf, z, area, data)
data[vie] = c_fluid
elseif data[vie] == c_air
or data[vie] == c_apple
or data[vie] == c_leaves then
data[vie] = c_fluid
end
if data[viw] == c_tree then
skylands:remtree(x - 1, yasurf, z, area, data)
data[viw] = c_fluid
elseif data[viw] == c_air
or data[viw] == c_apple
or data[viw] == c_leaves then
data[viw] = c_fluid
end
if data[vin] == c_tree then
skylands:remtree(x, yasurf, z + 1, area, data)
data[vin] = c_fluid
elseif data[vin] == c_air
or data[vin] == c_apple
or data[vin] == c_leaves then
data[vin] = c_fluid
end
if data[vis] == c_tree then
skylands:remtree(x, yasurf, z - 1, area, data)
data[vis] = c_fluid
elseif data[vis] == c_air
or data[vis] == c_apple
or data[vis] == c_leaves then
data[vis] = c_fluid
end
end
end
end
if flab then
break
end
end
if flab then
break
end
end
--end
if flab then -- erase water from this y level
for z = z0, z1 do
for x = x0, x1 do
local vi = area:index(x, yasurf, z)
if data[vi] == c_fluid then
data[vi] = c_air
end
end
end
--print("no basin found at "..minetest.pos_to_string(p)..".")
else -- flow downwards add dirt
for z = z0, z1 do
for x = x0, x1 do
local vi = area:index(x, yasurf, z)
if data[vi] == c_fluid then
for y = yasurf - 1, yasurf - 15, -1 do
local viu = area:index(x, y, z)
if data[viu] == c_air then
data[viu] = c_under
elseif data[viu] == c_grass then
data[viu] = c_dirt
break
else
break
end
end
end
end
end
end
end
end
--end
--end
end

BIN
textures/Thumbs.db Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B