mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +01:00
Various adaptations on watershed
This commit is contained in:
parent
1135ac90c9
commit
be83517bb3
@ -221,137 +221,7 @@ if SINGLENODE then
|
||||
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
|
||||
end)
|
||||
|
||||
-- Spawn player function. Requires chunksize = 80 nodes (the default)
|
||||
|
||||
function spawnplayer(player)
|
||||
local TERCEN = -128
|
||||
local TERSCA = 512
|
||||
local XLSAMP = 0.1
|
||||
local BASAMP = 0.3
|
||||
local MIDAMP = 0.1
|
||||
local CANAMP = 0.4
|
||||
local ATANAMP = 1.1
|
||||
local BLENEXP = 2
|
||||
local xsp
|
||||
local ysp
|
||||
local zsp
|
||||
|
||||
local np_terrain = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=384, y=192, z=384},
|
||||
seed = 593,
|
||||
octaves = 5,
|
||||
persist = 0.67
|
||||
}
|
||||
local np_mid = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=768, y=768, z=1},
|
||||
seed = 85546,
|
||||
octaves = 5,
|
||||
persist = 0.5
|
||||
}
|
||||
local np_base = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=4096, y=4096, z=1},
|
||||
seed = 8890,
|
||||
octaves = 3,
|
||||
persist = 0.33
|
||||
}
|
||||
local np_xlscale = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=8192, y=8192, z=1},
|
||||
seed = -72,
|
||||
octaves = 3,
|
||||
persist = 0.33
|
||||
}
|
||||
|
||||
local nobj_terrain = nil
|
||||
local nobj_mid = nil
|
||||
local nobj_base = nil
|
||||
local nobj_xlscale = nil
|
||||
|
||||
for chunk = 1, 64 do
|
||||
print ("[watershed] searching for spawn "..chunk)
|
||||
local x0 = 80 * math.random(-32, 32) - 32
|
||||
local z0 = 80 * math.random(-32, 32) - 32
|
||||
local y0 = -32
|
||||
local x1 = x0 + 79
|
||||
local z1 = z0 + 79
|
||||
local y1 = 47
|
||||
local sidelen = 80
|
||||
local chulensxyz = {x=sidelen, y=sidelen+2, z=sidelen}
|
||||
local chulensxz = {x=sidelen, y=sidelen, z=1}
|
||||
local minposxyz = {x=x0, y=y0-1, z=z0}
|
||||
local minposxz = {x=x0, y=z0}
|
||||
|
||||
nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, chulensxyz)
|
||||
nobj_mid = nobj_mid or minetest.get_perlin_map(np_mid, chulensxz)
|
||||
nobj_base = nobj_base or minetest.get_perlin_map(np_base, chulensxz)
|
||||
nobj_xlscale = nobj_xlscale or minetest.get_perlin_map(np_xlscale, chulensxz)
|
||||
|
||||
local nvals_terrain = nobj_terrain:get3dMap_flat(minposxyz)
|
||||
local nvals_mid = nobj_mid:get2dMap_flat(minposxz)
|
||||
local nvals_base = nobj_base:get2dMap_flat(minposxz)
|
||||
local nvals_xlscale = nobj_xlscale:get2dMap_flat(minposxz)
|
||||
|
||||
local nixz = 1
|
||||
local nixyz = 1
|
||||
for z = z0, z1 do
|
||||
for y = y0, y1 do
|
||||
for x = x0, x1 do
|
||||
local n_absterrain = math.abs(nvals_terrain[nixyz])
|
||||
local n_absmid = math.abs(nvals_mid[nixz])
|
||||
local n_absbase = math.abs(nvals_base[nixz])
|
||||
local n_xlscale = nvals_xlscale[nixz]
|
||||
|
||||
local n_invbase = (1 - n_absbase)
|
||||
local terblen = (math.max(n_invbase, 0)) ^ BLENEXP
|
||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
||||
local densitybase = n_invbase * BASAMP + n_xlscale * XLSAMP + grad
|
||||
local densitymid = n_absmid * MIDAMP + densitybase
|
||||
local canexp = 0.5 + terblen * 0.5
|
||||
local canamp = terblen * CANAMP
|
||||
local density = n_absterrain ^ canexp * canamp * n_absmid + densitymid
|
||||
|
||||
if y >= 1 and density > -0.005 and density < 0 then
|
||||
ysp = y + 1
|
||||
xsp = x
|
||||
zsp = z
|
||||
break
|
||||
end
|
||||
nixz = nixz + 1
|
||||
nixyz = nixyz + 1
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz - 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz + 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
end
|
||||
print ("[watershed] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
||||
end
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
spawnplayer(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
spawnplayer(player)
|
||||
return true
|
||||
end)
|
||||
-- Spawn player function is useless in minetestforfun
|
||||
end
|
||||
|
||||
-- ABM
|
||||
@ -371,11 +241,7 @@ minetest.register_abm({
|
||||
|
||||
-- Appletree sapling
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"watershed:appling"},
|
||||
interval = 57,
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
function default.grow_tree(pos)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
@ -389,16 +255,11 @@ minetest.register_abm({
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Pine sapling
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"watershed:pineling"},
|
||||
interval = 59,
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
function default.grow_pine_tree(pos)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
@ -412,39 +273,13 @@ minetest.register_abm({
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Acacia sapling
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"watershed:acacialing"},
|
||||
interval = 61,
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local pos1 = {x=x-4, y=y-3, z=z-4}
|
||||
local pos2 = {x=x+4, y=y+6, z=z+4}
|
||||
local emin, emax = vm:read_from_map(pos1, pos2)
|
||||
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||
local data = vm:get_data()
|
||||
watershed_acaciatree(x, y, z, area, data)
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end,
|
||||
})
|
||||
-- Acacia sapling is already defined in Moretrees
|
||||
|
||||
-- Jungletree sapling
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"watershed:jungling"},
|
||||
interval = 63,
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
function default.grow_jungle_tree(pos)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
@ -458,5 +293,4 @@ minetest.register_abm({
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ minetest.register_alias("watershed:appling", "default:sapling")
|
||||
|
||||
minetest.register_alias("watershed:acaciatree", "moretrees:acacia_tree")
|
||||
|
||||
minetest.register_alias("watershed:acacialeaf", "moretrees:acacia_sapling")
|
||||
minetest.register_alias("watershed:acacialeaf", "moretrees:acacia_leaves")
|
||||
|
||||
minetest.register_alias("watershed:acacialing", "moretrees:acacia_sapling")
|
||||
|
||||
@ -43,7 +43,7 @@ minetest.register_alias("watershed:stone", "default:stone")
|
||||
minetest.register_alias("watershed:cactus", "default:cactus")
|
||||
|
||||
minetest.register_node("watershed:goldengrass", {
|
||||
description = "Golden grass",
|
||||
description = "Golden Grass",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"watershed_goldengrass.png"},
|
||||
inventory_image = "watershed_goldengrass.png",
|
||||
@ -61,7 +61,7 @@ minetest.register_node("watershed:goldengrass", {
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:drygrass", {
|
||||
description = "Dry grass",
|
||||
description = "Dry Dirt",
|
||||
tiles = {"watershed_drygrass.png"},
|
||||
is_ground_content = false,
|
||||
groups = {crumbly=1,soil=1},
|
||||
@ -102,7 +102,9 @@ minetest.register_node("watershed:freshice", {
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("watershed:cloud", {
|
||||
minetest.register_alias("watershed:cloud", "default:cloud")
|
||||
|
||||
minetest.override_item("default:cloud", {
|
||||
description = "Cloud",
|
||||
drawtype = "glasslike",
|
||||
tiles = {"watershed_cloud.png"},
|
||||
@ -141,159 +143,17 @@ minetest.register_alias("watershed:pinewood", "default:pinewood")
|
||||
|
||||
|
||||
|
||||
minetest.register_node("watershed:freshwater", {
|
||||
description = "Freshwater source",
|
||||
inventory_image = minetest.inventorycube("watershed_freshwater.png"),
|
||||
drawtype = "liquid",
|
||||
tiles = {
|
||||
{
|
||||
name="watershed_freshwateranim.png",
|
||||
animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0}
|
||||
}
|
||||
},
|
||||
special_tiles = {
|
||||
{
|
||||
name="watershed_freshwateranim.png",
|
||||
animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0},
|
||||
backface_culling = false,
|
||||
}
|
||||
},
|
||||
alpha = WATER_ALPHA,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "watershed:freshwaterflow",
|
||||
liquid_alternative_source = "watershed:freshwater",
|
||||
liquid_viscosity = WATER_VISC,
|
||||
liquid_renewable = false,
|
||||
liquid_range = 2,
|
||||
post_effect_color = {a=64, r=100, g=150, b=200},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1},
|
||||
})
|
||||
minetest.register_alias("watershed:freshwater", "default:river_water_source")
|
||||
|
||||
minetest.register_node("watershed:freshwaterflow", {
|
||||
description = "Flowing freshwater",
|
||||
inventory_image = minetest.inventorycube("watershed_freshwater.png"),
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"watershed_freshwater.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
image="watershed_freshwaterflowanim.png",
|
||||
backface_culling=false,
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
|
||||
},
|
||||
{
|
||||
image="watershed_freshwaterflowanim.png",
|
||||
backface_culling=true,
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
|
||||
},
|
||||
},
|
||||
alpha = WATER_ALPHA,
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_flowing = "watershed:freshwaterflow",
|
||||
liquid_alternative_source = "watershed:freshwater",
|
||||
liquid_viscosity = WATER_VISC,
|
||||
liquid_renewable = false,
|
||||
liquid_range = 2,
|
||||
post_effect_color = {a=64, r=100, g=150, b=200},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1},
|
||||
})
|
||||
minetest.register_alias("watershed:freshwaterflow", "default:river_water_flowing")
|
||||
|
||||
minetest.register_alias("watershed:lava", "default:lava_source")
|
||||
|
||||
minetest.register_alias("watershed:lavaflow", "default:lava_flowing")
|
||||
|
||||
minetest.register_node("watershed:mixwater", {
|
||||
description = "Mixed water source",
|
||||
inventory_image = minetest.inventorycube("watershed_mixwater.png"),
|
||||
drawtype = "liquid",
|
||||
tiles = {
|
||||
{
|
||||
name="watershed_mixwateranim.png",
|
||||
animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0}
|
||||
}
|
||||
},
|
||||
special_tiles = {
|
||||
{
|
||||
name="watershed_mixwateranim.png",
|
||||
animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0},
|
||||
backface_culling = false,
|
||||
}
|
||||
},
|
||||
alpha = WATER_ALPHA,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "watershed:mixwaterflow",
|
||||
liquid_alternative_source = "watershed:mixwater",
|
||||
liquid_viscosity = WATER_VISC,
|
||||
liquid_renewable = false,
|
||||
liquid_range = 2,
|
||||
post_effect_color = {a=64, r=100, g=120, b=200},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1},
|
||||
})
|
||||
minetest.register_alias("watershed:mixwater", "default:river_water_source")
|
||||
|
||||
minetest.register_node("watershed:mixwaterflow", {
|
||||
description = "Flowing mixed water",
|
||||
inventory_image = minetest.inventorycube("watershed_mixwater.png"),
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"watershed_mixwater.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
image="watershed_mixwaterflowanim.png",
|
||||
backface_culling=false,
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
|
||||
},
|
||||
{
|
||||
image="watershed_mixwaterflowanim.png",
|
||||
backface_culling=true,
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
|
||||
},
|
||||
},
|
||||
alpha = WATER_ALPHA,
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_flowing = "watershed:mixwaterflow",
|
||||
liquid_alternative_source = "watershed:mixwater",
|
||||
liquid_viscosity = WATER_VISC,
|
||||
liquid_renewable = false,
|
||||
liquid_range = 2,
|
||||
post_effect_color = {a=64, r=100, g=120, b=200},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1},
|
||||
})
|
||||
minetest.register_alias("watershed:mixwaterflow", "default:river_water_flowing")
|
||||
|
||||
-- Items
|
||||
|
||||
@ -340,16 +200,10 @@ bucket.register_liquid(
|
||||
"watershed:freshwaterflow",
|
||||
"watershed:bucket_freshwater",
|
||||
"watershed_bucketfreshwater.png",
|
||||
"WS Fresh Water Bucket"
|
||||
"River Water Bucket"
|
||||
)
|
||||
|
||||
bucket.register_liquid(
|
||||
"watershed:lava",
|
||||
"watershed:lavaflow",
|
||||
"watershed:bucket_lava",
|
||||
"bucket_lava.png",
|
||||
"WS Lava Bucket"
|
||||
)
|
||||
minetest.register_alias("watershed:bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
-- Fuel
|
||||
|
||||
@ -359,19 +213,3 @@ minetest.register_craft({
|
||||
burntime = 60,
|
||||
replacements = {{"watershed:bucket_lava", "bucket:bucket_empty"}},
|
||||
})
|
||||
|
||||
-- Register stairs and slabs
|
||||
|
||||
stairs.register_stair_and_slab("acaciawood", "watershed:acaciawood",
|
||||
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
|
||||
{"watershed_acaciawood.png"},
|
||||
"Acaciawood stair",
|
||||
"Acaciawood slab",
|
||||
default.node_sound_wood_defaults())
|
||||
|
||||
stairs.register_stair_and_slab("pinewood", "watershed:pinewood",
|
||||
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
|
||||
{"watershed_pinewood.png"},
|
||||
"Pinewood stair",
|
||||
"Pinewood slab",
|
||||
default.node_sound_wood_defaults())
|
||||
|
Loading…
Reference in New Issue
Block a user