sun type planet

master
Thomas Rudin 2019-06-15 17:18:51 +02:00
parent 89026cbf33
commit f235c33d92
6 changed files with 86 additions and 4 deletions

View File

@ -12,6 +12,10 @@ local MP = minetest.get_modpath("planetoidgen")
dofile(MP.."/planets.lua")
dofile(MP.."/vacuum.lua")
dofile(MP.."/mapgen.lua")
dofile(MP.."/nodes/sun.lua")
dofile(MP.."/planets/classm.lua")
dofile(MP.."/planets/sun.lua")
print("[OK] Planetoidgen")

View File

@ -51,6 +51,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
local t1 = minetest.get_us_time()
local micros = t1 -t0
minetest.log("debug", "[planetoidgen] mapgen for " .. minetest.pos_to_string(minp) .. " took " .. micros .. " us")
minetest.log("action", "[planetoidgen] mapgen for " .. minetest.pos_to_string(minp) .. ", type: " .. planet.type .. " took " .. micros .. " us")
end)

38
nodes/sun.lua Normal file
View File

@ -0,0 +1,38 @@
minetest.register_node("planetoidgen:sun", {
description = "Sun matter",
tiles = {
{
name = "default_lava_source_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
{
name = "default_lava_source_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
},
paramtype = "light",
light_source = default.LIGHT_MAX,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
damage_per_second = 4 * 2,
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
groups = { radioactive = 20, igniter = 1 }
})

View File

@ -6,5 +6,6 @@
},
"name": "xy",
"type": "class-m",
"radius": 300
"radius": 300,
"airshell": true
}]

34
planets/sun.lua Normal file
View File

@ -0,0 +1,34 @@
local c_ignore = minetest.get_content_id("ignore")
local c_air = minetest.get_content_id("air")
local c_sun = minetest.get_content_id("planetoidgen:sun")
planetoidgen.planettypes["sun"] = 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
data[i] = c_sun
end -- distance check
end--y
end--x
end--z
vm:set_data(data)
vm:set_lighting({day=15, night=0})
vm:write_to_map()
end

View File

@ -10,7 +10,12 @@ if has_vacuum_mod then
if distance < planet.radius+160 then
-- planet is here, not space (plus safety margin for air shell)
return false
if planet.airshell then
return false
else
-- no airshell == space
return true
end
end
end
@ -24,7 +29,7 @@ if has_vacuum_mod then
if distance < planet.radius+10 and distance > planet.radius-10 then
-- no air/vacuum interaction at planet boundary
return true
return planet.airshell
end
end