Differences From
Artifact [cdaabd4e00]:
3 3
4 4 function world.date()
5 5 local days = minetest.get_day_count()
6 6 local year = math.floor(days / world.planet.orbit);
7 7 local day = days % world.planet.orbit;
8 8 return {
9 9 year = year, day = day;
10 - season = day / world.planet.orbit;
10 + season = day / world.planet.orbit + 0.5; -- begin summer
11 11 }
12 12 end
13 13 local lerp = lib.math.lerp
14 14
15 15 local function gradient(grad, pos)
16 16 local n = #grad
17 17 if n == 1 then return grad[1] end
................................................................................
18 18 local op = pos*(n-1)
19 19 local idx = math.floor(op)
20 20 local t = op-idx
21 21 return lerp(t, grad[1 + idx], grad[2 + idx])
22 22 end
23 23
24 24 local altitudeCooling = 10 / 100
25 +local heatRange = {min = -70, max = 70} -- translate mt temps into real temps
25 26
26 27 -- this function provides the basis for temperature calculation,
27 28 -- which is performed by adding this value to the ambient temperature,
28 29 -- determined by querying nearby group:heatSource items in accordance
29 30 -- with the inverse-square law
30 31 function world.climate.eval(pos, tod, season)
31 32 local data = minetest.get_biome_data(pos)
32 33 local biome = world.ecology.biomes.db[minetest.get_biome_name(data.biome)]
33 34 local heat, humid = data.heat, data.humidity
35 + heat = lerp(heat/100, heatRange.min, heatRange.max)
34 36 tod = tod or minetest.get_timeofday()
35 37 heat = lerp(math.abs(tod - 0.5)*2, heat, heat + biome.nightTempDelta)
38 +-- print('base heat', heat)
36 39
37 40 local td = world.date()
38 41 heat = heat + gradient(biome.seasonalTemp, season or td.season)
42 +-- print('seasonal heat', heat)
39 43 if pos.y > 0 then
40 44 heat = heat - pos.y*altitudeCooling
41 45 end
46 +-- print('altitude heat', heat)
42 47
43 48 return {
44 49 surfaceTemp = heat;
45 50 waterTemp = heat + biome.waterTempDelta;
46 51 surfaceHumid = humid;
47 52 }
48 53 end