starlit  Diff

Differences From Artifact [7074af2318]:

To Artifact [b2784a81d4]:


   243    243   				number = 0xffffff;
   244    244   			}
   245    245   			m.destroy = function()
   246    246   				luser:hud_remove(m.meter)
   247    247   				luser:hud_remove(m.readout)
   248    248   			end
   249    249   			m.update = function()
   250         -				local v,txt,color,txtcolor = def.measure(luser,def)
          250  +				local v,txt,color,txtcolor,hl,hlcolor = def.measure(luser,def)
   251    251   				v = math.max(0, math.min(1, v))
   252    252   				local n = math.floor(v*16) + 1
   253         -				local img = hudAdjustBacklight(lib.image('starlit-ui-meter.png'))
   254         -					:colorize(color or def.color)
          253  +				local function adjust(img)
          254  +					return hudAdjustBacklight(lib.image(img)):shift(color or def.color)
          255  +				end
          256  +				local img = adjust 'starlit-ui-meter.png'
   255    257   				if def.flipX then
   256    258   					img = img:transform 'FX'
   257    259   				end
   258    260   				img = img:render()
   259    261   				img = img .. '^[verticalframe:17:' .. tostring(17 - n)
          262  +				if hl then
          263  +					hl = math.floor(hl*16) + 1
          264  +					local hi = hudAdjustBacklight(lib.image 'starlit-ui-meter-hl.png')
          265  +						:shift(hlcolor or def.color)
          266  +						:render()
          267  +					hi = hi .. '^[verticalframe:17:' .. tostring(17 - hl)
          268  +					img = string.format('%s^(%s)', img, hi)
          269  +				end
          270  +				img = string.format('%s^(%s)', img, adjust 'starlit-ui-meter-readout.png':render())
   260    271   				luser:hud_change(m.meter, 'text', img)
   261    272   				if txt then
   262    273   					luser:hud_change(m.readout, 'text', txt)
   263    274   				end
   264    275   				if txtcolor then
   265    276   					luser:hud_change(m.readout, 'number', txtcolor:hex())
   266    277   				end
................................................................................
   385    396   			self.hud.elt.temp = self:attachMeter {
   386    397   				name = 'temp';
   387    398   				align = {x=1, y=-1};
   388    399   				pos = {x=0, y=1};
   389    400   				ofs = {x=20, y=-20};
   390    401   				measure = function(user)
   391    402   					local warm = self:effectiveStat 'warmth'
   392         -					local n, color if warm < 0 then
   393         -						n = math.min(100, -warm)
   394         -						color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
   395         -					else
   396         -						n = math.min(100,  warm)
   397         -						color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
          403  +					local exposure = starlit.world.climate.temp(self.entity:get_pos())
          404  +
          405  +					local function tempVals(warm, br)
          406  +						local n if warm < 0 then
          407  +							n = math.min(100, -warm)
          408  +-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
          409  +						else
          410  +							n = math.min(100,  warm)
          411  +-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
          412  +						end
          413  +						local hue = lib.math.gradient({
          414  +							205, 264, 281, 360 + 17
          415  +						}, (warm + 50) / 100) % 360
          416  +						return {hue=hue, sat = 1, lum = br}, n
   398    417   					end
          418  +
          419  +					local color, n = tempVals(warm,0)
          420  +					local hlcolor, hl = tempVals(exposure,.5)
   399    421   					local txt = string.format("%s°", math.floor(warm))
   400         -					return (n/50), txt, color
          422  +					return (n/50), txt, color, nil, (hl/50), hlcolor
   401    423   				end;
   402    424   			}
   403    425   			self.hud.elt.geiger = self:attachMeter {
   404    426   				name = 'geiger';
   405    427   				align = {x=-1, y=-1};
   406    428   				pos = {x=1, y=1};
   407    429   				ofs = {x=-20, y=-20};
................................................................................
   512    534   			local s = self:getSuit()
   513    535   			if s:powerState() == 'off' then return false end
   514    536   			local sd = s:def()
   515    537   			local w = self:effectiveStat 'warmth'
   516    538   			local kappa = starlit.constant.heat.thermalConductivity
   517    539   			local insul = sd.temp.insulation
   518    540   			local dt = (kappa * (1-insul)) * (t - w)
   519         -			print('dt', dt, dump(sd.temp))
   520    541   			if (dt > 0 and          dt  > sd.temp.maxCool)
   521    542   			or (dt < 0 and math.abs(dt) > sd.temp.maxHeat) then return false end
   522    543   			return true
   523    544   		end;
   524    545   		-- will exposure to temperature t cause the player eventual harm
   525    546   		tempHazard = function(self, t)
   526    547   			local tr = self:species().tempRange.survivable