Use voxelmanip for stability scanning. New design tree grown by voxelmanip
This commit is contained in:
parent
afac21fb6b
commit
d7e546bae9
@ -1,5 +1,5 @@
|
|||||||
moonrealm 0.8.0 by paramat
|
moonrealm 0.8.1 by paramat
|
||||||
For Minetest 0.4.9 dev with custom skybox commit
|
For Minetest 0.4.10
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: code WTFPL, textures CC BY-SA
|
Licenses: code WTFPL, textures CC BY-SA
|
||||||
|
|
||||||
|
@ -4,38 +4,69 @@ function moonrealm_appletree(pos)
|
|||||||
local x = pos.x
|
local x = pos.x
|
||||||
local y = pos.y
|
local y = pos.y
|
||||||
local z = pos.z
|
local z = pos.z
|
||||||
for j = -2, -1 do
|
local top = 3 + math.random(2)
|
||||||
local nodename = minetest.get_node({x=x,y=y+j,z=z}).name
|
local c_tree = minetest.get_content_id("default:tree")
|
||||||
if nodename ~= "moonrealm:soil" then
|
local c_apple = minetest.get_content_id("default:apple")
|
||||||
|
local c_appleleaf = minetest.get_content_id("moonrealm:appleleaf")
|
||||||
|
local c_soil = minetest.get_content_id("moonrealm:soil")
|
||||||
|
local c_lsair = minetest.get_content_id("moonrealm:air")
|
||||||
|
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
local pos1 = {x=x-2, y=y-2, z=z-2}
|
||||||
|
local pos2 = {x=x+2, y=y+5, z=z+2}
|
||||||
|
local emin, emax = vm:read_from_map(pos1, pos2)
|
||||||
|
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||||
|
local data = vm:get_data()
|
||||||
|
|
||||||
|
for j = -2, -1 do -- check for soil
|
||||||
|
local vi = area:index(x, y + j, z)
|
||||||
|
if data[vi] ~= c_soil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for j = 1, 5 do
|
for j = 1, 5 do -- check for life support air
|
||||||
local nodename = minetest.get_node({x=x,y=y+j,z=z}).name
|
for i = -2, 2 do
|
||||||
if nodename ~= "moonrealm:air" then
|
for k = -2, 2 do
|
||||||
|
local vi = area:index(x + i, y + j, z + k)
|
||||||
|
if data[vi] ~= c_lsair then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for j = -2, 4 do
|
end
|
||||||
if j >= 1 then
|
end
|
||||||
|
for j = -2, top do -- spawn appletree
|
||||||
|
if j == top - 1 or j == top then
|
||||||
for i = -2, 2 do
|
for i = -2, 2 do
|
||||||
for k = -2, 2 do
|
for k = -2, 2 do
|
||||||
local nodename = minetest.get_node({x=x+i,y=y+j+1,z=z+k}).name
|
local vi = area:index(x + i, y + j, z + k)
|
||||||
if math.random() > (math.abs(i) + math.abs(k)) / 16 then
|
if math.random(5) ~= 2 then
|
||||||
if math.random(13) == 2 then
|
data[vi] = c_appleleaf
|
||||||
minetest.add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="default:apple"})
|
if j == top and math.random() < 0.04 then -- apples hang from leaves
|
||||||
else
|
local viu = area:index(x + i, y + j - 1, z + k)
|
||||||
minetest.add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="moonrealm:leaves"})
|
data[viu] = c_apple
|
||||||
end
|
end
|
||||||
else
|
|
||||||
minetest.add_node({x=x+i,y=y+j+1,z=z+k},{name="moonrealm:air"})
|
|
||||||
minetest.get_meta({x=x+i,y=y+j+1,z=z+k}):set_int("spread", 16)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif j == top - 2 then
|
||||||
|
for i = -1, 1 do
|
||||||
|
for k = -1, 1 do
|
||||||
|
if math.abs(i) + math.abs(k) == 2 then
|
||||||
|
local vi = area:index(x + i, y + j, z + k)
|
||||||
|
data[vi] = c_tree
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local vi = area:index(x, y + j, z)
|
||||||
|
data[vi] = c_tree
|
||||||
end
|
end
|
||||||
minetest.add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:write_to_map()
|
||||||
|
vm:update_map()
|
||||||
|
|
||||||
print ("[moonrealm] Appletree sapling grows")
|
print ("[moonrealm] Appletree sapling grows")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -164,8 +195,8 @@ minetest.register_abm({
|
|||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moonrealm:sapling"},
|
nodenames = {"moonrealm:sapling"},
|
||||||
interval = 57,
|
interval = 31,
|
||||||
chance = 3,
|
chance = 5,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
moonrealm_appletree(pos)
|
moonrealm_appletree(pos)
|
||||||
end,
|
end,
|
||||||
@ -173,7 +204,7 @@ minetest.register_abm({
|
|||||||
|
|
||||||
-- Singlenode option
|
-- Singlenode option
|
||||||
|
|
||||||
local SINGLENODE = false
|
local SINGLENODE = true
|
||||||
|
|
||||||
if SINGLENODE then
|
if SINGLENODE then
|
||||||
minetest.register_on_mapgen_init(function(mgparams)
|
minetest.register_on_mapgen_init(function(mgparams)
|
||||||
|
49
init.lua
49
init.lua
@ -1,34 +1,35 @@
|
|||||||
-- moonrealm 0.8.0 by paramat
|
-- moonrealm 0.8.1 by paramat
|
||||||
-- For Minetest 0.4.9 dev with custom skybox commit
|
-- For Minetest 0.4.10
|
||||||
-- Depends default
|
-- Depends default
|
||||||
-- Licenses: code WTFPL, textures CC BY-SA
|
-- Licenses: code WTFPL, textures CC BY-SA
|
||||||
|
|
||||||
-- auto-set skybox and 'override day/night ratio' in singlenode and stacked realm modes
|
-- speed increase by using voxelmanip for scanning chunk below / initialising stability table
|
||||||
-- constant fissure width
|
-- LVM appletree, new design, spawn with LVM
|
||||||
|
-- TODO
|
||||||
|
-- on-dignode, air, hydroponics, soil drying by LVM too
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local XMIN = -8000 -- -- Approx horizontal limits. 1/4 of normal realm size.
|
local XMIN = -8000 -- Approx horizontal limits. 1/4 of normal realm size.
|
||||||
local XMAX = 8000
|
local XMAX = 8000
|
||||||
local ZMIN = -8000
|
local ZMIN = -8000
|
||||||
local ZMAX = 8000
|
local ZMAX = 8000
|
||||||
|
-- Change the 3 parameters below when changing between singlenode and stacked modes
|
||||||
|
local YMIN = -8000 -- Approx lower limit
|
||||||
|
local GRADCEN = 1 -- Gradient centre / terrain centre average level
|
||||||
|
local YMAX = 8000 -- Approx upper limit
|
||||||
|
|
||||||
local YMIN = 8000 -- -- Approx lower limit
|
local FOOT = true -- Footprints in dust
|
||||||
local GRADCEN = 16000 -- -- Gradient centre / terrain centre average level
|
local CENAMP = 64 -- Grad centre amplitude, terrain centre is varied by this
|
||||||
local YMAX = 24000 -- -- Approx upper limit
|
local HIGRAD = 128 -- Surface generating noise gradient above gradcen, controls depth of upper terrain
|
||||||
|
local LOGRAD = 128 -- Surface generating noise gradient below gradcen, controls depth of lower terrain
|
||||||
local FOOT = true -- -- Footprints in dust
|
local HEXP = 0.5 -- Noise offset exponent above gradcen, 1 = normal 3D perlin terrain
|
||||||
local CENAMP = 64 -- -- Grad centre amplitude, terrain centre is varied by this
|
local LEXP = 2 -- Noise offset exponent below gradcen
|
||||||
local HIGRAD = 128 -- -- Surface generating noise gradient above gradcen, controls depth of upper terrain
|
local STOT = 0.04 -- Stone density threshold, depth of dust
|
||||||
local LOGRAD = 128 -- -- Surface generating noise gradient below gradcen, controls depth of lower terrain
|
local ICECHA = 1 / (13*13*13) -- Ice chance per dust node at terrain centre, decreases with altitude
|
||||||
local HEXP = 0.5 -- -- Noise offset exponent above gradcen, 1 = normal 3D perlin terrain
|
local ICEGRAD = 128 -- Ice gradient, vertical distance for no ice
|
||||||
local LEXP = 2 -- -- Noise offset exponent below gradcen
|
local ORECHA = 7*7*7 -- Ore 1/x chance per stone node
|
||||||
local STOT = 0.04 -- -- Stone density threshold, depth of dust
|
local TFIS = 0.01 -- Fissure threshold. Controls size of fissures
|
||||||
local ICECHA = 1 / (13*13*13) -- -- Ice chance per dust node at terrain centre, decreases with altitude
|
|
||||||
local ICEGRAD = 128 -- -- Ice gradient, vertical distance for no ice
|
|
||||||
local ORECHA = 7*7*7 -- -- Ore 1/x chance per stone node
|
|
||||||
|
|
||||||
local TFIS = 0.01 -- -- Fissure threshold. Controls size of fissures
|
|
||||||
|
|
||||||
|
|
||||||
-- 3D noise for terrain
|
-- 3D noise for terrain
|
||||||
@ -237,14 +238,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local nid = 1 -- 2D noise index
|
local nid = 1 -- 2D noise index
|
||||||
local stable = {}
|
local stable = {}
|
||||||
for z = z0, z1 do
|
for z = z0, z1 do
|
||||||
|
local viu = area:index(x0, y0-1, z)
|
||||||
for x = x0, x1 do
|
for x = x0, x1 do
|
||||||
local si = x - x0 + 1
|
local si = x - x0 + 1
|
||||||
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
|
local nodid = data[viu]
|
||||||
if nodename == "moonrealm:vacuum" then
|
if nodid == c_vacuum then
|
||||||
stable[si] = false
|
stable[si] = false
|
||||||
else -- solid nodes and ignore in ungenerated chunks
|
else -- solid nodes and ignore in ungenerated chunks
|
||||||
stable[si] = true
|
stable[si] = true
|
||||||
end
|
end
|
||||||
|
viu = viu + 1
|
||||||
end
|
end
|
||||||
for y = y0, y1 do
|
for y = y0, y1 do
|
||||||
local vi = area:index(x0, y, z) -- LVM index for first node in x row
|
local vi = area:index(x0, y, z) -- LVM index for first node in x row
|
||||||
|
@ -235,8 +235,8 @@ minetest.register_node("moonrealm:sapling", {
|
|||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:leaves", {
|
minetest.register_node("moonrealm:appleleaf", {
|
||||||
description = "MR Leaves",
|
description = "Appletree leaves",
|
||||||
drawtype = "allfaces_optional",
|
drawtype = "allfaces_optional",
|
||||||
visual_scale = 1.3,
|
visual_scale = 1.3,
|
||||||
tiles = {"default_leaves.png"},
|
tiles = {"default_leaves.png"},
|
||||||
@ -247,7 +247,7 @@ minetest.register_node("moonrealm:leaves", {
|
|||||||
max_items = 1,
|
max_items = 1,
|
||||||
items = {
|
items = {
|
||||||
{items = {"moonrealm:sapling"},rarity = 20,},
|
{items = {"moonrealm:sapling"},rarity = 20,},
|
||||||
{items = {"moonrealm:leaves"},}
|
{items = {"moonrealm:appleleaf"},}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user