Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mapgen = {}
- function mapgen:apollo_gen(area, data, pos)--minetest.register_on_generated(function(minp, maxp, seed)
- --local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
- --local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
- --local data = vm:get_data()
- --local y1 = maxp.y
- --local y0 = minp.y
- local px = pos.x
- local py = pos.y
- local pz = pos.z
- --fire up the voxel manipulator
- local vm = minetest.get_voxel_manip()
- local p1 = {x=px-16,y=py-16,z=pz-16}
- local p2 = {x=px+16,y=py+16,z=pz+16}
- pmin, pmax = vm:read_from_map(p1,p2)
- local area = VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}
- local data = vm:get_data()
- print("generating APOLLO MODULE")
- --moontest node content_ids
- local c_dust = minetest.get_content_id("moontest:dust")
- local c_bas = minetest.get_content_id("moontest:basalt")
- local c_hl = minetest.get_content_id("moontest:hlsource")
- local c_msto = minetest.get_content_id("moontest:stone")
- local c_vac = minetest.get_content_id("moontest:vacuum")
- local c_mair = minetest.get_content_id("moontest:air")
- local c_ashield = minetest.get_content_id("moontest:air_shield")
- --default node content_ids
- local c_sto = minetest.get_content_id("default:stone")
- local c_wood = minetest.get_content_id("default:wood")
- local c_glass = minetest.get_content_id("default:glass")
- local c_sblock = minetest.get_content_id("default:steelblock")
- local c_gblock = minetest.get_content_id("default:goldblock")
- local c_cblock = minetest.get_content_id("default:copperblock")
- --mesecons node content_ids
- local c_mesecon = minetest.get_content_id("mesecons:wire_00000000_off")
- local c_lamp = minetest.get_content_id("mesecons_lamp:lamp_off")
- local c_power = minetest.get_content_id("mesecons_powerplant:power_plant")
- --air
- local c_air = minetest.get_content_id("air")
- local yasurf = 0 -- y of above surface node at center of moon
- local stable = true -- is ground solid or liquid?
- for y = py + 16, py - 10, -1 do
- local vi = area:index(px, y, pz)
- local c_node = data[vi]
- if y == py+16 and c_node ~= c_vac and c_node ~= c_air then -- if top node solid
- break
- elseif c_node == c_hl then
- yasurf = y + 1
- stable = false
- break
- elseif c_node == c_dust or c_node == c_msto or c_node == c_bas then --if first surface node
- yasurf = y + 1 --set the position of the surface
- break
- end
- end
- yasurf = py
- --clear out an area for the apollo module
- for x = pmin.x, pmax.x do--px - 13, px + 13 do
- for z = pmin.z, pmax.z do--pz - 13, pz + 13 do
- for y = yasurf, yasurf + 16 do
- local vi = area:index(x, y, z)
- data[vi] = c_vac
- end
- end
- end
- --add a layer ground beneath of it
- for x = px - 15, px + 15 do
- for z = pz - 15, pz + 15 do
- for y = yasurf - 10, yasurf do
- local vi = area:index(x, y, z)
- data[vi] = c_msto
- end
- end
- end
- --create the module
- --start with gold base
- for y = yasurf + 4, yasurf + 6 do
- for x = px-4, px+4 do
- for z = pz - 4, pz + 4 do
- local vi = area:index(x, y, z)
- data[vi] = c_gblock
- end
- end
- for x = px - 2, px + 2 do
- local vi = area:index(x, y, pz + 5)
- data[vi] = c_gblock
- local vi = area:index(x, y, pz - 5)
- data[vi] = c_gblock
- end
- for z = pz - 2, pz + 2 do
- local vi = area:index(px + 5, y, z)
- data[vi] = c_gblock
- local vi = area:index(px - 5, y, z)
- data[vi] = c_gblock
- end
- end
- --create air
- for y = yasurf + 7, yasurf + 13 do
- for x = px - 3, px + 3 do
- for z = pz - 3, pz + 3 do
- local vi = area:index(x,y,z)
- data[vi] = c_mair
- end
- end
- end
- --create cabin
- for y = yasurf + 9, yasurf + 10 do
- for x = px - 2, px + 2 do
- z = pz - 5
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- z =pz + 5
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- end
- for z = pz - 2, pz + 2 do
- x = px - 5
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- x = px + 5
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- end
- end
- for y = yasurf + 8, yasurf + 11 do
- for x = px - 3, px + 3 do
- z = pz - 4
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- z =pz + 4
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- end
- for z = pz - 3, pz + 3 do
- x = px - 4
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- x = px + 4
- local vi = area:index(x,y,z)
- data[vi] = c_sblock
- end
- end
- --write the voxel manipulator data back to world
- vm:set_data(data)
- vm:write_to_map(data)
- vm:update_map()
- end
- minetest.register_on_newplayer(function(player)
- pos = player:getpos()
- mapgen:apollo_gen(area, data, pos)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement