Add noise buffer optimisation. Improve spawn search. Improve tree. Make ABMs not catch_up
This commit is contained in:
parent
faf558f43b
commit
1035fcd01c
35
README.txt
35
README.txt
@ -11,92 +11,117 @@ Spacesuit
|
||||
To avoid asphyxiation in vacuum put a spacesuit in your inventory.
|
||||
|
||||
Mesetinted helmet
|
||||
|
||||
-C-
|
||||
-G-
|
||||
-S-
|
||||
|
||||
C = default mese crystal (mese tint)
|
||||
G = default glass
|
||||
S = default steel ingot
|
||||
|
||||
Lifesupport backpack
|
||||
|
||||
SSS
|
||||
S-S
|
||||
SMS
|
||||
|
||||
S = default steel ingot
|
||||
M = default mese block (power source)
|
||||
|
||||
Spacesuit
|
||||
|
||||
WHW
|
||||
-L-
|
||||
W-W
|
||||
|
||||
W = wool white (fabric)
|
||||
H = moonrealm helmet
|
||||
L = moonrealm lifesupport
|
||||
|
||||
Moon stone brick x 4
|
||||
|
||||
MM
|
||||
MM
|
||||
|
||||
M = moon stone
|
||||
|
||||
Moon stone stair x 4
|
||||
|
||||
M
|
||||
MM
|
||||
|
||||
M = moon stone
|
||||
|
||||
Moon stone slab x 4
|
||||
|
||||
MM
|
||||
|
||||
M = moon stone
|
||||
|
||||
Default furnace
|
||||
You can cook moon dust to moonrealm glass, use mese crystal as fuel.
|
||||
|
||||
MMM
|
||||
M-M
|
||||
MMM
|
||||
|
||||
M = moon stone
|
||||
|
||||
Airgen
|
||||
Place in the centre of a sealed habitat.
|
||||
Moonrealm air will spread to a distance of roughly 16 nodes.
|
||||
|
||||
SIS
|
||||
IMI
|
||||
SIS
|
||||
|
||||
S = default steel ingot
|
||||
I = moonrealm waterice
|
||||
M = default mese block (power source)
|
||||
|
||||
Airlock with light source
|
||||
Walk through it, life support air cannot pass through.
|
||||
|
||||
S-S
|
||||
SMS
|
||||
S-S
|
||||
|
||||
S = default steel ingot
|
||||
M = default mese block (power source)
|
||||
|
||||
Light x 8
|
||||
|
||||
GGG
|
||||
GMG
|
||||
GGG
|
||||
|
||||
G = moonrealm glass
|
||||
M = default mese block (power source)
|
||||
|
||||
Light x 1
|
||||
GC
|
||||
|
||||
G+C
|
||||
|
||||
shapeless crafting
|
||||
G = moonrealm glass
|
||||
C = default mese crystal (power source)
|
||||
|
||||
Default water source
|
||||
Ice spawns in dust at mid to low altitudes
|
||||
|
||||
I
|
||||
shapeless crafting
|
||||
|
||||
I = moonrealm waterice
|
||||
|
||||
Hydroponic liquid source
|
||||
Hydroponic liquid will saturate the 5x5 node area of dust around it, to a depth of 5 nodes,
|
||||
changing it to moonrealm soil. You can grow any farming mod crop in the soil.
|
||||
A depth of 2 soil nodes with moonrealm air above is needed for a moonrealm sapling to grow.
|
||||
Hydroponic liquid will saturate the 5x5x5 node volume of dust around it,
|
||||
changing it to moonrealm soil. For growth a moonrealm sapling requires a
|
||||
1 node depth of moonrealm soil and 5x5x5 nodes of moonrealm air around it.
|
||||
|
||||
LLL
|
||||
LIL
|
||||
LLL
|
||||
|
||||
L = moonrealm appleleaf
|
||||
I = moonrealm waterice
|
||||
|
@ -4,7 +4,6 @@ function moonrealm_appletree(pos)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
local top = 3 + math.random(2)
|
||||
local c_tree = minetest.get_content_id("default:tree")
|
||||
local c_apple = minetest.get_content_id("default:apple")
|
||||
local c_appleleaf = minetest.get_content_id("moonrealm:appleleaf")
|
||||
@ -12,20 +11,19 @@ function moonrealm_appletree(pos)
|
||||
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 pos1 = {x = x - 2, y = y - 1, z = z - 2}
|
||||
local pos2 = {x = x + 2, y = y + 4, 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
|
||||
end
|
||||
-- check for soil
|
||||
local vi = area:index(x, y - 1, z)
|
||||
if data[vi] ~= c_soil then
|
||||
return
|
||||
end
|
||||
|
||||
for j = 1, 5 do -- check for life support air
|
||||
for j = 1, 4 do -- check for air
|
||||
for k = -2, 2 do
|
||||
local vi = area:index(x - 2, y + j, z + k)
|
||||
for i = -2, 2 do
|
||||
@ -37,15 +35,17 @@ function moonrealm_appletree(pos)
|
||||
end
|
||||
end
|
||||
|
||||
for j = -2, top do
|
||||
if j == top - 1 or j == top then
|
||||
for k = -2, 2 do
|
||||
local vi = area:index(x - 2, y + j, z + k)
|
||||
for j = 4, -1, -1 do
|
||||
if j >= 2 or j <= 4 then
|
||||
for k = -2, 2 do -- branches, leaves, apples underneath
|
||||
local vi = area:index(x - 1, y + j, z + k)
|
||||
local viu = area:index(x - 2, y + j - 1, z + k)
|
||||
for i = -2, 2 do
|
||||
if math.random() < 0.8 then
|
||||
if math.abs(i) + math.abs(k) == 2 then
|
||||
data[vi] = c_tree
|
||||
elseif math.random() < 0.8 then
|
||||
data[vi] = c_appleleaf
|
||||
if j == top and math.random() < 0.08 then
|
||||
if math.random() < 0.08 then
|
||||
data[viu] = c_apple
|
||||
end
|
||||
end
|
||||
@ -53,17 +53,7 @@ function moonrealm_appletree(pos)
|
||||
viu = viu + 1
|
||||
end
|
||||
end
|
||||
elseif j == top - 2 then
|
||||
for k = -1, 1 do
|
||||
local vi = area:index(x - 1, y + j, z + k)
|
||||
for i = -1, 1 do
|
||||
if math.abs(i) + math.abs(k) == 2 then
|
||||
data[vi] = c_tree
|
||||
end
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
else
|
||||
else -- trunk
|
||||
local vi = area:index(x, y + j, z)
|
||||
data[vi] = c_tree
|
||||
end
|
||||
@ -135,6 +125,7 @@ minetest.register_abm({
|
||||
neighbors = {"moonrealm:vacuum"},
|
||||
interval = 13,
|
||||
chance = 9,
|
||||
catch_up = false,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local spread = minetest.get_meta(pos):get_int("spread")
|
||||
if spread <= 0 then
|
||||
@ -185,6 +176,7 @@ minetest.register_abm({
|
||||
neighbors = {"moonrealm:dust", "moonrealm:dustprint1", "moonrealm:dustprint2"},
|
||||
interval = 29,
|
||||
chance = 9,
|
||||
catch_up = false,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
@ -233,6 +225,7 @@ minetest.register_abm({
|
||||
nodenames = {"moonrealm:soil"},
|
||||
interval = 31,
|
||||
chance = 9,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
@ -280,6 +273,7 @@ minetest.register_abm({
|
||||
nodenames = {"moonrealm:sapling"},
|
||||
interval = 31,
|
||||
chance = 7,
|
||||
catch_up = false,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
moonrealm_appletree(pos)
|
||||
end,
|
||||
|
83
init.lua
83
init.lua
@ -239,6 +239,18 @@ local nobj_terblen = nil
|
||||
local nobj_gradcen = nil
|
||||
|
||||
|
||||
-- Create noise buffers
|
||||
|
||||
local nbuf_terrain = {}
|
||||
local nbuf_terralt = {}
|
||||
local nbuf_fissure = {}
|
||||
local nbuf_fault = {}
|
||||
|
||||
local nbuf_smooth = {}
|
||||
local nbuf_terblen = {}
|
||||
local nbuf_gradcen = {}
|
||||
|
||||
|
||||
-- On generated function
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
@ -287,14 +299,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
nobj_terblen = nobj_terblen or minetest.get_perlin_map(np_terblen, pmaplens2d)
|
||||
nobj_gradcen = nobj_gradcen or minetest.get_perlin_map(np_gradcen, pmaplens2d)
|
||||
|
||||
local nvals_terrain = nobj_terrain:get3dMap_flat(minpos3d)
|
||||
local nvals_terralt = nobj_terralt:get3dMap_flat(minpos3d)
|
||||
local nvals_fissure = nobj_fissure:get3dMap_flat(minpos3d)
|
||||
local nvals_fault = nobj_fault :get3dMap_flat(minpos3d)
|
||||
local nvals_terrain = nobj_terrain:get3dMap_flat(minpos3d, nbuf_terrain)
|
||||
local nvals_terralt = nobj_terralt:get3dMap_flat(minpos3d, nbuf_terralt)
|
||||
local nvals_fissure = nobj_fissure:get3dMap_flat(minpos3d, nbuf_fissure)
|
||||
local nvals_fault = nobj_fault :get3dMap_flat(minpos3d, nbuf_fault)
|
||||
|
||||
local nvals_smooth = nobj_smooth :get2dMap_flat(minpos2d)
|
||||
local nvals_terblen = nobj_terblen:get2dMap_flat(minpos2d)
|
||||
local nvals_gradcen = nobj_gradcen:get2dMap_flat(minpos2d)
|
||||
local nvals_smooth = nobj_smooth :get2dMap_flat(minpos2d, nbuf_smooth)
|
||||
local nvals_terblen = nobj_terblen:get2dMap_flat(minpos2d, nbuf_terblen)
|
||||
local nvals_gradcen = nobj_gradcen:get2dMap_flat(minpos2d, nbuf_gradcen)
|
||||
|
||||
local ni3d = 1
|
||||
local ni2d = 1
|
||||
@ -408,17 +420,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
end)
|
||||
|
||||
|
||||
-- Spawn point, localise here to make available to all spawn functions
|
||||
|
||||
local xsp, ysp, zsp
|
||||
|
||||
-- Find spawn function, dependant on chunk size of 80 nodes (TODO allow any chunksize)
|
||||
|
||||
local function moonrealm_find_spawn()
|
||||
local PSCA = 16
|
||||
xsp = nil
|
||||
ysp = nil
|
||||
zsp = nil
|
||||
|
||||
local nobj_terrain = nil
|
||||
local nobj_terralt = nil
|
||||
@ -428,7 +433,7 @@ local function moonrealm_find_spawn()
|
||||
local nobj_terblen = nil
|
||||
local nobj_gradcen = nil
|
||||
|
||||
for chunk = 1, 64 do
|
||||
for chunk = 1, 128 do
|
||||
print ("[moonrealm] searching for spawn " .. chunk)
|
||||
|
||||
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||
@ -494,51 +499,43 @@ local function moonrealm_find_spawn()
|
||||
stable[si] = true
|
||||
-- just above ground, smooth terrain, away from faults
|
||||
elseif stable[si] and density < 0 and terblen == 1 and
|
||||
math.abs(nvals_fault[ni3d]) > 0.5 then
|
||||
ysp = y + 3
|
||||
xsp = x
|
||||
zsp = z
|
||||
break
|
||||
math.abs(nvals_fault[ni3d]) > 0.25 then
|
||||
return {x = x, y = y + 3, z = z}
|
||||
end
|
||||
|
||||
ni3d = ni3d + 1
|
||||
ni2d = ni2d + 1
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
ni2d = ni2d - chulens
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
ni2d = ni2d + chulens
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return {x = 0, y = GRADCEN, z = 0} -- fallback spawn point
|
||||
end
|
||||
|
||||
|
||||
-- Spawn newplayer function
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
moonrealm_find_spawn()
|
||||
|
||||
local spawn_pos = moonrealm_find_spawn()
|
||||
local xsp = spawn_pos.x
|
||||
local ysp = spawn_pos.y
|
||||
local zsp = spawn_pos.z
|
||||
print ("[moonrealm] spawn player (" .. xsp .. " " .. ysp .. " " .. zsp .. ")")
|
||||
player:setpos({x = xsp, y = ysp, z = zsp})
|
||||
player:setpos(spawn_pos)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
inv:add_item("main", "moonrealm:spacesuit 2")
|
||||
inv:add_item("main", "moonrealm:sapling 4")
|
||||
inv:add_item("main", "default:pick_diamond 4")
|
||||
inv:add_item("main", "default:shovel_diamond 4")
|
||||
inv:add_item("main", "default:axe_diamond 4")
|
||||
inv:add_item("main", "default:apple 64")
|
||||
inv:add_item("main", "moonrealm:airlock 4")
|
||||
inv:add_item("main", "moonrealm:airgen 4")
|
||||
inv:add_item("main", "moonrealm:hlsource 4")
|
||||
inv:add_item("main", "default:apple 64")
|
||||
inv:add_item("main", "default:pick_diamond 4")
|
||||
inv:add_item("main", "default:axe_diamond 4")
|
||||
inv:add_item("main", "default:shovel_diamond 4")
|
||||
inv:add_item("main", "moonrealm:sapling 4")
|
||||
inv:add_item("main", "moonrealm:spacesuit 2")
|
||||
|
||||
-- create spawn egg
|
||||
local vm = minetest.get_voxel_manip()
|
||||
@ -583,15 +580,15 @@ end)
|
||||
-- Respawn player function
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
moonrealm_find_spawn()
|
||||
|
||||
print ("[moonrealm] respawn player (" .. xsp .. " " .. ysp .. " " .. zsp .. ")")
|
||||
player:setpos({x = xsp, y = ysp, z = zsp})
|
||||
local spawn_pos = moonrealm_find_spawn()
|
||||
print ("[moonrealm] respawn player (" .. spawn_pos.x .. " " ..
|
||||
spawn_pos.y .. " " .. spawn_pos.z .. ")")
|
||||
player:setpos(spawn_pos)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
inv:add_item("main", "moonrealm:spacesuit")
|
||||
inv:add_item("main", "default:pick_diamond")
|
||||
inv:add_item("main", "default:apple 16")
|
||||
inv:add_item("main", "moonrealm:spacesuit")
|
||||
|
||||
return true
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user