stone planet

master
Thomas Rudin 2019-06-15 18:01:39 +02:00
parent 666e810871
commit 1157a7faec
3 changed files with 67 additions and 0 deletions

View File

@ -18,6 +18,7 @@ dofile(MP.."/nodes/sun.lua")
dofile(MP.."/planets/classh.lua")
dofile(MP.."/planets/classp.lua")
dofile(MP.."/planets/classm.lua")
dofile(MP.."/planets/classn.lua")
dofile(MP.."/planets/sun.lua")
print("[OK] Planetoidgen")

65
planets/classn.lua Normal file
View File

@ -0,0 +1,65 @@
local c_shell = minetest.get_content_id("default:stone")
local c_top = minetest.get_content_id("default:stone")
planetoidgen.planettypes["class-n"] = function(planet, minp, maxp, seed)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local data = vm:get_data()
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
for z=minp.z,maxp.z do
for x=minp.x,maxp.x do
for y=minp.y,maxp.y do
local i = area:index(x,y,z)
local pos = area:position(i)
local distance_to_center = vector.distance(pos, planet.pos)
-- check if inside radius
if distance_to_center <= planet.radius then
local is_outer_shell = pos.y < planet.pos.y
local is_top = pos.y == planet.pos.y
if is_outer_shell then
data[i] = c_shell
elseif is_top then
data[i] = c_top
end
end -- distance check
end--y
end--x
end--z
vm:set_data(data)
if minp.y < planet.pos.y then
print("[planetoidgen] generating ores for " .. minetest.pos_to_string(minp))
-- generate ores
minetest.generate_ores(vm, minp, {
x = maxp.x,
y = math.min(maxp.y, planet.pos.y-1),
z = maxp.z
})
end
if minp.y <= planet.pos.y and maxp.y >= planet.pos.y then
print("[planetoidgen] generating decos for " .. minetest.pos_to_string(minp))
-- generate decorations
minetest.generate_decorations(vm, {
x = minp.x, y = planet.pos.y-20, z=minp.z
}, {
x = maxp.x, y = planet.pos.y+10, z=maxp.z
})
end
vm:set_lighting({day=15, night=0})
vm:write_to_map()
end

View File

@ -5,6 +5,7 @@
See: https://en.wikipedia.org/wiki/Star_Trek_planet_classification
* `class-m` earth like, flat (various dirt top layers and stone body)
* `class-n` all stone, flat
* `class-h` desert planet (desert-sand top layer and desert-sandstone body)
* `class-p` ice planet (snowblock top layer and ice body)
* `sun` radioactive sun (single lava-like node)