]> git.lizzy.rs Git - Crafter.git/blob - mods/aether/biomes.lua
remove server debug
[Crafter.git] / mods / aether / biomes.lua
1 local 
2 minetest,math
3 =
4 minetest,math
5
6
7 minetest.register_biome({
8         name = "aether",
9         node_top = "air",
10         depth_top = 1,
11         node_filler = "air",
12         depth_filler = 3,
13         node_riverbed = "air",
14         depth_riverbed= 0,
15         node_stone = "air",
16         node_water = "air",
17         node_dungeon = "air",
18         node_dungeon_alt = "air",
19         node_dungeon_stair = "air",
20         node_cave_liquid = "air",
21         vertical_blend = 0,
22         y_max = 31000,
23         y_min = 21000,
24         heat_point = -100,
25         humidity_point = -100,
26 })
27
28 --this is from https://github.com/paramat/lvm_example/blob/master/init.lua
29 --hi paramat :D
30
31 -- Set the 3D noise parameters for the terrain.
32 local np_terrain = {
33         offset = 0,
34         scale = 1,
35         spread = {x = 200, y = 100, z = 200},
36         seed = tonumber(minetest.get_mapgen_setting("seed")) or math.random(0,999999999),
37         octaves = 5,
38         persist = 0.63,
39         lacunarity = 2.0,
40         --flags = ""
41 }
42
43
44 -- Set singlenode mapgen (air nodes only).
45 -- Disable the engine lighting calculation since that will be done for a
46 -- mapchunk of air nodes and will be incorrect after we place nodes.
47 --minetest.set_mapgen_params({mgname = "singlenode", flags = "nolight"})
48 -- Get the content IDs for the nodes used.
49
50 local nobj_terrain = nil
51 local n_pos = {}
52 local node2 = ""
53 local vi = {}
54 local sidelen = {}
55 local permapdims3d  = {}
56 local nobj_terrain = {}
57 local vm = {}
58 local emin = {}
59 local emax = {}
60 local area = {}
61 local ni = 1
62 local density_noise  = {}
63
64 local nvals_terrain = {}
65 local data = {}
66
67 local content_id = minetest.get_name_from_content_id
68 local get_map = minetest.get_perlin_map
69 local get_mapgen_object = minetest.get_mapgen_object
70
71 local c_dirt = minetest.get_content_id("aether:dirt")
72 local c_stone = minetest.get_content_id("aether:stone")
73 local c_air = minetest.get_content_id("air")
74 local c_grass = minetest.get_content_id("aether:grass")
75 -- On generated function.
76
77 -- 'minp' and 'maxp' are the minimum and maximum positions of the mapchunk that
78 -- define the 3D volume.
79 minetest.register_on_generated(function(minp, maxp, seed)
80         --aether starts at 21000
81         if minp.y < 21000 then
82                 return
83         end
84
85         -- Start time of mapchunk generation.
86         --local t0 = minetest.get_us_time()/1000000
87
88         sidelen = maxp.x - minp.x + 1
89
90         permapdims3d = {x = sidelen, y = sidelen, z = sidelen}
91
92         nobj_terrain = get_map(np_terrain, permapdims3d)
93
94         nobj_terrain:get_3d_map_flat(minp, nvals_terrain)
95
96         ni = 1
97
98         vm, emin, emax = get_mapgen_object("voxelmanip")
99
100         area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
101
102         vm:get_data(data)
103
104         for z = minp.z, maxp.z do
105         for y = minp.y, maxp.y do
106
107                 vi = area:index(minp.x, y, z)
108                 for x = minp.x, maxp.x do
109
110                         density_noise = nvals_terrain[ni]
111
112                         if density_noise > 0.1 then
113                                 data[vi] = c_dirt
114                         else
115                                 --force create grass
116                                 n_pos = area:index(x,y-1,z)
117                                 node2 = content_id(data[n_pos])
118                                 if node2 == "aether:dirt" then
119                                         data[n_pos] = c_grass
120                                 end
121                         end
122
123                         ni = ni + 1
124
125                         vi = vi + 1
126                 end
127         end
128         end
129
130
131         vm:set_data(data)
132
133         vm:set_lighting({day=15,night=0}, minp, maxp)
134
135         vm:write_to_map()
136                 
137                 
138         -- Liquid nodes were placed so set them flowing.
139         --vm:update_liquids()
140
141         -- Print generation time of this mapchunk.
142         --local chugent = math.ceil((minetest.get_us_time()/1000000- t0) * 1000)
143         --print ("[lvm_example] Mapchunk generation time " .. chugent .. " ms")
144 end)