Differences From
Artifact [d79dc9efc2]:
176 176 -- player is in -30°C weather, and has an internal temperature of
177 177 -- 10°C. then:
178 178 -- κ = .1°C/C/s (which is apparently 100mHz)
179 179 -- Tₚ = 10°C
180 180 -- Tₑ = -30°C
181 181 -- d = Tₑ − Tₚ = -40°C
182 182 -- ΔT = κ×d = -.4°C/s
183 + -- too cold:
184 + -- x = beginning of danger zone
185 + -- κ × (x - Tₚ) = y where y < Tₚ
183 186 -- our final change in temperature is computed as tΔC where t is time
184 - local kappa = .05
187 + local kappa = starlit.constant.heat.thermalConductivity
185 188 for name,user in pairs(starlit.activeUsers) do
186 189 local tr = user:species().tempRange
187 190 local t = starlit.world.climate.temp(user.entity:get_pos())
191 +
192 + do -- this bit probably belongs in starlit:bio but we do it here in order
193 + -- to spare ourselves another call into the dark swamp of climate.temp
194 + local urg = 1
195 + local function alarm(kind)
196 + user:alarm(urg, kind, nil, {
197 + elt = user.hud.elt.temp, ofs = {x=100,y=0};
198 + tex = 'starlit-ui-alert-'..kind..'.png';
199 + })
200 + end
201 + local hz = user:tempHazard(t)
202 + local tr = user:species().tempRange.survivable
203 + if hz == 'cold' then
204 + if tr[1] - t > 7 then urg = 2 end
205 + alarm 'temp-cold'
206 + elseif hz == 'hot' then
207 + if t - tr[2] > 7 then urg = 2 end
208 + alarm 'temp-hot'
209 + end
210 + end
211 +
188 212 local insul = 0
189 213 local naked = user:naked()
190 214 local suitDef
191 215 if not naked then
192 216 suitDef = user:suitStack():get_definition()
193 217 insul = suitDef._starlit.suit.temp.insulation
194 218 end
................................................................................
223 247 end
224 248 end
225 249
226 250 user:statDelta('warmth', tgt - warm) -- dopey but w/e
227 251
228 252 warm = tgt -- for the sake of readable code
229 253
254 + -- does this belong in starlit:bio? unsure tbh
230 255 if warm < tSafeMin or warm > tSafeMax then
231 256 local dv
232 257 if warm < tSafeMin then
233 258 dv = math.abs(warm - tSafeMin)
234 259 else
235 260 dv = math.abs(warm - tSafeMax)
236 261 end