starlit  Diff

Differences From Artifact [7074af2318]:

To Artifact [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