starlit  Check-in [9d4ddb7701]

Overview
Comment:fix colors, add grass
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9d4ddb770122e23390fd1e3064583c984348924cc57ecfbb66e2d2f6d8aef5c6
User & Date: lexi on 2024-05-04 02:18:17
Other Links: manifest | tags
Context
2024-05-04
22:41
add beginnings of matter compiler UI, check in missing files check-in: 0e7832a24c user: lexi tags: trunk
02:18
fix colors, add grass check-in: 9d4ddb7701 user: lexi tags: trunk
2024-05-03
21:00
add primitive thermal hazard LEDs; further documentation check-in: 511814aace user: lexi tags: trunk
Changes

Modified mods/starlit-eco/plants.lua from [798314c789] to [c84dadb0c1].

10
11
12
13
14
15
16





















































17
18
19
20
21
22
23
24
25
26
27
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	a = strdrop(a)
	b = strdrop(b)
	return {
		max_items = a.max_items + b.max_items;
		items = lib.tbl.append(a.items, b.items);
	}
end





















































local function stalkPlant(def)
	local function stage(s, drops, swap)
		return {
			tex = lib.image(string.format('starlit-eco-plant-stalk%s.png',s)):shift(def.color);
			drop = drops;
			swap = swap;
		}
	end
	local function plantMatter(opts)
		local dps = {
			seed = def.seed;
................................................................................
		name = def.name;
		stages = stages;
		decoration = def.decoration;
		meshOpt = 3;
	})
end

local function simpleDrop(rarity, what)
	return {
		max_items = 1;
		items = {
			{rarity = rarity, items = {what}};
		};
	};
end

function stalkPlantAuto(def)
	local id = def.id
	local id_berries = def.id .. '_berry'
	local id_seed = def.id .. '_seed'

	local p = lib.tbl.proto({}, def)
................................................................................
	biolum = 5;
	leaf = {
		color = lib.color(.6, .8, .8);
		drop = simpleDrop(2, 'starlit_eco:moondrop_petal');
	};
	berries = {
		desc = "The fruits of the moondrop are not very nutritious, but their peculiar sweet-sour flavor profile makes them one of Farthest Shadow's great delicacies";
		color = lib.color(1,0,.4);
		mass = 1;
		impact = starlit.type.impact {
			nutrition = 10;
			hydration = 0.05;
			taste = 1*60;
		};
	};
................................................................................
}

stalkPlantAuto {
	id = 'starlit_eco:dustrose';
	name = "Dust Rose";
	fiber = simpleDrop(2, 'starlit_eco:fiber');
	seed = {};
	color = lib.color(.3, .1, .2);
	leaf = {
		color = lib.color(.7, .4, .8);
		drop = simpleDrop(2, 'starlit_eco:dustrose_petal');
	};
	decoration = {
		place_on = 'starlit:greengraze';
		fill_ratio = 0.03;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|







 







<
<
<
<
<
<
<
<







 







|







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
117
118
119
120
121
122
123








124
125
126
127
128
129
130
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
	a = strdrop(a)
	b = strdrop(b)
	return {
		max_items = a.max_items + b.max_items;
		items = lib.tbl.append(a.items, b.items);
	}
end

local function simpleDrop(rarity, what)
	return {
		max_items = 1;
		items = {
			{rarity = rarity, items = {what}};
		};
	};
end

local function biomeGrass(biomes, seed)
	return function(def)
		world.ecology.plants.link(def.id, {
			stages = {{
				tex = def.tex;
				drop = simpleDrop(4, 'starlit_eco:fiber');
			}};
			decoration = {
				deco_type = 'simple';
				place_on = 'starlit:greengraze';
				biomes = biomes;
				noise_params = {
					offset = def.ofs;
					spread = vector.new(10,10,10);
					seed = seed;
					octaves = 3;
				};
			}
		})
	end
end

do gg = biomeGrass({'starlit:steppe', 'starlit:forest'}, 0x5e8fa0)
	gg {
		id = 'starlit_eco:greengraze_low';
		name = 'Low Greengraze';
		tex = 'starlit-eco-plant-grass-sprig.png';
		ofs = -.3;
	}
	gg {
		id = 'starlit_eco:greengraze_high';
		name = 'High Greengraze';
		tex = 'starlit-eco-plant-grass-high.png';
		ofs = -.5;
	}
	gg {
		id = 'starlit_eco:greengraze_tall';
		name = 'Tall Greengraze';
		tex = 'starlit-eco-plant-grass-tall.png';
		ofs = -.7;
	}
end

local function stalkPlant(def)
	local function stage(s, drops, swap)
		return {
			tex = lib.image(string.format('starlit-eco-plant-stalk%s.png',s)):colorize(def.color);
			drop = drops;
			swap = swap;
		}
	end
	local function plantMatter(opts)
		local dps = {
			seed = def.seed;
................................................................................
		name = def.name;
		stages = stages;
		decoration = def.decoration;
		meshOpt = 3;
	})
end










function stalkPlantAuto(def)
	local id = def.id
	local id_berries = def.id .. '_berry'
	local id_seed = def.id .. '_seed'

	local p = lib.tbl.proto({}, def)
................................................................................
	biolum = 5;
	leaf = {
		color = lib.color(.6, .8, .8);
		drop = simpleDrop(2, 'starlit_eco:moondrop_petal');
	};
	berries = {
		desc = "The fruits of the moondrop are not very nutritious, but their peculiar sweet-sour flavor profile makes them one of Farthest Shadow's great delicacies";
		color = lib.color(.5,0,.1);
		mass = 1;
		impact = starlit.type.impact {
			nutrition = 10;
			hydration = 0.05;
			taste = 1*60;
		};
	};
................................................................................
}

stalkPlantAuto {
	id = 'starlit_eco:dustrose';
	name = "Dust Rose";
	fiber = simpleDrop(2, 'starlit_eco:fiber');
	seed = {};
	color = lib.color(.9, .8, .3);
	leaf = {
		color = lib.color(.7, .4, .8);
		drop = simpleDrop(2, 'starlit_eco:dustrose_petal');
	};
	decoration = {
		place_on = 'starlit:greengraze';
		fill_ratio = 0.03;

Modified mods/starlit-eco/trees.lua from [a9d406a1cb] to [d43bf4970e].

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	_starlit = woodProps{};
})


starlit.item.food.link('starlit_eco:lambent_pine_berry', {
	name = 'Lambent Pine Berry';
	desc = 'Though packed with human-compatible nutrients, these berries are almost painfully sour when eaten raw.';
	tex = lib.image('starlit-eco-plant-berry-bunch.png'):shift{hue=180,sat=-30,lum=30}:render();
	impact = starlit.type.impact {
		nutrition = 150;
		taste = -2 * 60;
	};
	mass = 2;
})

starlit.item.seed.link('starlit_eco:lambent_pine_seed', {
	name = 'Lambent Pine Seed';
	tex = lib.image('starlit-eco-plant-seeds.png'):shift{hue=150, sat=-50, lum=80}:render();
	grow = {kind = 'tree', id = 'starlit_eco:lambent_pine'};
})

minetest.register_node('starlit_eco:lambent_pine_bulb', {
	description = 'Lambent Pine Bulb';
	drawtype = 'nodebox';
	connects_to = {'starlit_eco:lambent_pine_needles'};







|









|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	_starlit = woodProps{};
})


starlit.item.food.link('starlit_eco:lambent_pine_berry', {
	name = 'Lambent Pine Berry';
	desc = 'Though packed with human-compatible nutrients, these berries are almost painfully sour when eaten raw.';
	tex = lib.image('starlit-eco-plant-berry-bunch.png'):shift{hue=180,sat=-.3,lum=3}:render();
	impact = starlit.type.impact {
		nutrition = 150;
		taste = -2 * 60;
	};
	mass = 2;
})

starlit.item.seed.link('starlit_eco:lambent_pine_seed', {
	name = 'Lambent Pine Seed';
	tex = lib.image('starlit-eco-plant-seeds.png'):shift{hue=150, sat=-.5, lum=.8}:render();
	grow = {kind = 'tree', id = 'starlit_eco:lambent_pine'};
})

minetest.register_node('starlit_eco:lambent_pine_bulb', {
	description = 'Lambent Pine Bulb';
	drawtype = 'nodebox';
	connects_to = {'starlit_eco:lambent_pine_needles'};

Modified mods/starlit/user.lua from [7074af2318] to [b2784a81d4].

243
244
245
246
247
248
249
250
251
252
253
254


255
256
257
258
259









260
261
262
263
264
265
266
...
385
386
387
388
389
390
391



392
393
394
395
396
397
398








399
400
401
402
403
404
405
406
407
...
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
				number = 0xffffff;
			}
			m.destroy = function()
				luser:hud_remove(m.meter)
				luser:hud_remove(m.readout)
			end
			m.update = function()
				local v,txt,color,txtcolor = def.measure(luser,def)
				v = math.max(0, math.min(1, v))
				local n = math.floor(v*16) + 1
				local img = hudAdjustBacklight(lib.image('starlit-ui-meter.png'))
					:colorize(color or def.color)


				if def.flipX then
					img = img:transform 'FX'
				end
				img = img:render()
				img = img .. '^[verticalframe:17:' .. tostring(17 - n)









				luser:hud_change(m.meter, 'text', img)
				if txt then
					luser:hud_change(m.readout, 'text', txt)
				end
				if txtcolor then
					luser:hud_change(m.readout, 'number', txtcolor:hex())
				end
................................................................................
			self.hud.elt.temp = self:attachMeter {
				name = 'temp';
				align = {x=1, y=-1};
				pos = {x=0, y=1};
				ofs = {x=20, y=-20};
				measure = function(user)
					local warm = self:effectiveStat 'warmth'



					local n, color if warm < 0 then
						n = math.min(100, -warm)
						color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
					else
						n = math.min(100,  warm)
						color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
					end








					local txt = string.format("%s°", math.floor(warm))
					return (n/50), txt, color
				end;
			}
			self.hud.elt.geiger = self:attachMeter {
				name = 'geiger';
				align = {x=-1, y=-1};
				pos = {x=1, y=1};
				ofs = {x=-20, y=-20};
................................................................................
			local s = self:getSuit()
			if s:powerState() == 'off' then return false end
			local sd = s:def()
			local w = self:effectiveStat 'warmth'
			local kappa = starlit.constant.heat.thermalConductivity
			local insul = sd.temp.insulation
			local dt = (kappa * (1-insul)) * (t - w)
			print('dt', dt, dump(sd.temp))
			if (dt > 0 and          dt  > sd.temp.maxCool)
			or (dt < 0 and math.abs(dt) > sd.temp.maxHeat) then return false end
			return true
		end;
		-- will exposure to temperature t cause the player eventual harm
		tempHazard = function(self, t)
			local tr = self:species().tempRange.survivable







|


|
|
>
>





>
>
>
>
>
>
>
>
>







 







>
>
>
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>

|







 







<







243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
...
534
535
536
537
538
539
540

541
542
543
544
545
546
547
				number = 0xffffff;
			}
			m.destroy = function()
				luser:hud_remove(m.meter)
				luser:hud_remove(m.readout)
			end
			m.update = function()
				local v,txt,color,txtcolor,hl,hlcolor = def.measure(luser,def)
				v = math.max(0, math.min(1, v))
				local n = math.floor(v*16) + 1
				local function adjust(img)
					return hudAdjustBacklight(lib.image(img)):shift(color or def.color)
				end
				local img = adjust 'starlit-ui-meter.png'
				if def.flipX then
					img = img:transform 'FX'
				end
				img = img:render()
				img = img .. '^[verticalframe:17:' .. tostring(17 - n)
				if hl then
					hl = math.floor(hl*16) + 1
					local hi = hudAdjustBacklight(lib.image 'starlit-ui-meter-hl.png')
						:shift(hlcolor or def.color)
						:render()
					hi = hi .. '^[verticalframe:17:' .. tostring(17 - hl)
					img = string.format('%s^(%s)', img, hi)
				end
				img = string.format('%s^(%s)', img, adjust 'starlit-ui-meter-readout.png':render())
				luser:hud_change(m.meter, 'text', img)
				if txt then
					luser:hud_change(m.readout, 'text', txt)
				end
				if txtcolor then
					luser:hud_change(m.readout, 'number', txtcolor:hex())
				end
................................................................................
			self.hud.elt.temp = self:attachMeter {
				name = 'temp';
				align = {x=1, y=-1};
				pos = {x=0, y=1};
				ofs = {x=20, y=-20};
				measure = function(user)
					local warm = self:effectiveStat 'warmth'
					local exposure = starlit.world.climate.temp(self.entity:get_pos())

					local function tempVals(warm, br)
						local n if warm < 0 then
							n = math.min(100, -warm)
-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
						else
							n = math.min(100,  warm)
-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
						end
						local hue = lib.math.gradient({
							205, 264, 281, 360 + 17
						}, (warm + 50) / 100) % 360
						return {hue=hue, sat = 1, lum = br}, n
					end

					local color, n = tempVals(warm,0)
					local hlcolor, hl = tempVals(exposure,.5)
					local txt = string.format("%s°", math.floor(warm))
					return (n/50), txt, color, nil, (hl/50), hlcolor
				end;
			}
			self.hud.elt.geiger = self:attachMeter {
				name = 'geiger';
				align = {x=-1, y=-1};
				pos = {x=1, y=1};
				ofs = {x=-20, y=-20};
................................................................................
			local s = self:getSuit()
			if s:powerState() == 'off' then return false end
			local sd = s:def()
			local w = self:effectiveStat 'warmth'
			local kappa = starlit.constant.heat.thermalConductivity
			local insul = sd.temp.insulation
			local dt = (kappa * (1-insul)) * (t - w)

			if (dt > 0 and          dt  > sd.temp.maxCool)
			or (dt < 0 and math.abs(dt) > sd.temp.maxHeat) then return false end
			return true
		end;
		-- will exposure to temperature t cause the player eventual harm
		tempHazard = function(self, t)
			local tr = self:species().tempRange.survivable

Modified mods/starlit/world.lua from [a2ac450e1c] to [5368f81f41].

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
	local day = days % world.planet.orbit;
	return {
		year = year, day = day;
		season = day / world.planet.orbit + 0.5; -- begin summer
	}
end
local lerp = lib.math.lerp


local function gradient(grad, pos)
	local n = #grad
	if n == 1 then return grad[1] end
	local op = pos*(n-1)
	local idx = math.floor(op)
	local t = op-idx
	return lerp(t, grad[1 + idx], grad[2 + idx])
end

local altitudeCooling = 10 / 100
local heatRange = {min = -70, max = 70} -- translate mt temps into real temps

-- this function provides the basis for temperature calculation,
-- which is performed by adding this value to the ambient temperature,
-- determined by querying nearby group:heatSource items in accordance
-- with the inverse-square law
function world.climate.eval(pos, tod, season)
	local data = minetest.get_biome_data(pos)
	local biome = world.ecology.biomes.db[minetest.get_biome_name(data.biome)]

	local heat, humid = data.heat, data.humidity
	heat = lerp(heat/100, heatRange.min, heatRange.max)
	tod = tod or minetest.get_timeofday()
	heat = lerp(math.abs(tod - 0.5)*2, heat, heat + biome.nightTempDelta)
-- 	print('base heat', heat)

	local td = world.date()







>

<
<
<
<
<
<
<
<
<

|








>







7
8
9
10
11
12
13
14
15









16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
	local day = days % world.planet.orbit;
	return {
		year = year, day = day;
		season = day / world.planet.orbit + 0.5; -- begin summer
	}
end
local lerp = lib.math.lerp
local gradient = lib.math.gradient










local altitudeCooling = 10 / 100
local heatRange = {min = -50, max = 50} -- translate mt temps into real temps

-- this function provides the basis for temperature calculation,
-- which is performed by adding this value to the ambient temperature,
-- determined by querying nearby group:heatSource items in accordance
-- with the inverse-square law
function world.climate.eval(pos, tod, season)
	local data = minetest.get_biome_data(pos)
	local biome = world.ecology.biomes.db[minetest.get_biome_name(data.biome)]
-- 	print('climate:', dump(data))
	local heat, humid = data.heat, data.humidity
	heat = lerp(heat/100, heatRange.min, heatRange.max)
	tod = tod or minetest.get_timeofday()
	heat = lerp(math.abs(tod - 0.5)*2, heat, heat + biome.nightTempDelta)
-- 	print('base heat', heat)

	local td = world.date()

Modified mods/vtlib/image.lua from [9575362639] to [33182947e9].

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
					color = lib.color(color)
				end
				color = color:to_hsl()
			end
			return image.change(self, {
				fx = lib.tbl.append(self.fx, {
					string.format('hsl:%s:%s:%s',
						color.hue, color.sat, color.lum)
				})
			})
		end;

		rehue = function(self, hue)
			return self.shift{hue=hue, sat=0, lum=0}
		end;







|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
					color = lib.color(color)
				end
				color = color:to_hsl()
			end
			return image.change(self, {
				fx = lib.tbl.append(self.fx, {
					string.format('hsl:%s:%s:%s',
						color.hue, color.sat*100, color.lum*100)
				})
			})
		end;

		rehue = function(self, hue)
			return self.shift{hue=hue, sat=0, lum=0}
		end;

Modified mods/vtlib/math.lua from [54a7601a0f] to [3edc02f291].

69
70
71
72
73
74
75








76
77
78
79
80
81
82
		end
	end

	return string.format("%s%s", val, unit)
end

function fn.lerp(t, a, b) return (1-t)*a + t*b end









function fn.trim(fl, prec)
	local fac = 10^prec
	return math.floor(fl * fac) / fac
end

function fn.sign(v)







>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
		end
	end

	return string.format("%s%s", val, unit)
end

function fn.lerp(t, a, b) return (1-t)*a + t*b end
function fn.gradient(grad, pos)
	local n = #grad
	if n == 1 then return grad[1] end
	local op = pos*(n-1)
	local idx = math.floor(op)
	local t = op-idx
	return fn.lerp(t, grad[1 + idx], grad[2 + idx])
end

function fn.trim(fl, prec)
	local fac = 10^prec
	return math.floor(fl * fac) / fac
end

function fn.sign(v)