starlit  Diff

Differences From Artifact [d79dc9efc2]:

To Artifact [a2ac450e1c]:


176
177
178
179
180
181
182



183
184
185
186
187





















188
189
190
191
192
193
194
...
223
224
225
226
227
228
229

230
231
232
233
234
235
236
	-- player is in -30°C weather, and has an internal temperature of
	-- 10°C. then:
	--   κ  = .1°C/C/s (which is apparently 100mHz)
	--   Tₚ =  10°C
	--   Tₑ = -30°C
	--   d  = Tₑ − Tₚ = -40°C
	--   ΔT = κ×d = -.4°C/s



	-- our final change in temperature is computed as tΔC where t is time
	local kappa = .05
	for name,user in pairs(starlit.activeUsers) do
		local tr = user:species().tempRange
		local t = starlit.world.climate.temp(user.entity:get_pos())





















		local insul = 0
		local naked = user:naked()
		local suitDef
		if not naked then
			suitDef = user:suitStack():get_definition()
			insul = suitDef._starlit.suit.temp.insulation
		end
................................................................................
			end
		end

		user:statDelta('warmth', tgt - warm) -- dopey but w/e

		warm = tgt -- for the sake of readable code


		if warm < tSafeMin or warm > tSafeMax then
			local dv
			if warm < tSafeMin then
				dv = math.abs(warm - tSafeMin)
			else
				dv = math.abs(warm - tSafeMax)
			end







>
>
>

|



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







 







>







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
	-- player is in -30°C weather, and has an internal temperature of
	-- 10°C. then:
	--   κ  = .1°C/C/s (which is apparently 100mHz)
	--   Tₚ =  10°C
	--   Tₑ = -30°C
	--   d  = Tₑ − Tₚ = -40°C
	--   ΔT = κ×d = -.4°C/s
	-- too cold:
	--		x = beginning of danger zone
	--    κ × (x - Tₚ) = y where y < Tₚ
	-- our final change in temperature is computed as tΔC where t is time
	local kappa = starlit.constant.heat.thermalConductivity
	for name,user in pairs(starlit.activeUsers) do
		local tr = user:species().tempRange
		local t = starlit.world.climate.temp(user.entity:get_pos())

		do -- this bit probably belongs in starlit:bio but we do it here in order
		   -- to spare ourselves another call into the dark swamp of climate.temp
		   local urg = 1
		   local function alarm(kind)
			   user:alarm(urg, kind, nil, {
				   elt = user.hud.elt.temp, ofs = {x=100,y=0};
				   tex = 'starlit-ui-alert-'..kind..'.png';
			   })
		   end
		   local hz = user:tempHazard(t)
			local tr = user:species().tempRange.survivable
		   if hz == 'cold' then
			   if tr[1] - t > 7 then urg = 2 end
			   alarm 'temp-cold'
		   elseif hz == 'hot' then
			   if t - tr[2] > 7 then urg = 2 end
			   alarm 'temp-hot'
		   end
		end

		local insul = 0
		local naked = user:naked()
		local suitDef
		if not naked then
			suitDef = user:suitStack():get_definition()
			insul = suitDef._starlit.suit.temp.insulation
		end
................................................................................
			end
		end

		user:statDelta('warmth', tgt - warm) -- dopey but w/e

		warm = tgt -- for the sake of readable code

		-- does this belong in starlit:bio? unsure tbh
		if warm < tSafeMin or warm > tSafeMax then
			local dv
			if warm < tSafeMin then
				dv = math.abs(warm - tSafeMin)
			else
				dv = math.abs(warm - tSafeMax)
			end